加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl批量处理

发布时间:2020-12-16 00:30:24 所属栏目:大数据 来源:网络整理
导读:和我shell那一篇文章需求一样 这个perl脚本是我找人写的 #!/bin/env?perl? ? use?strict;? ? opendir?DIRA,'/opt/test/20111201_import'?or?die?"$!n";? ? while?(my?$ fileA ?=? readdir ?DIRA)?{? ???chomp?$fileA;? ???next?unless?$ fileA ?=~?/.flv$/

和我shell那一篇文章需求一样 这个perl脚本是我找人写的

 
 
  1. #!/bin/env?perl?
  2. ?
  3. use?strict;?
  4. ?
  5. opendir?DIRA,'/opt/test/20111201_import'?or?die?"$!n";?
  6. ?
  7. while?(my?$fileA?=?readdir?DIRA)?{?
  8. ???chomp?$fileA;?
  9. ???next?unless?$fileA?=~?/.flv$/;?
  10. ???printf?"%sn",$fileA;?
  11. ?? #perl 如何调用系统命令 我主要就是想知道这个的
  12. system?"yamdi?-i?$fileA?-o?tmp_$fileA?-c?'modify?by?mytv365.com'";??
  13. }?
  14. ?
  15. close?DIRA;?
  16. ?
  17. opendir?DIRB,'/opt/test/20111201_import'?or?die?"$!n";?
  18. ?
  19. while?(my?$fileB?=?readdir?DIRB)?{?
  20. ???chomp?$fileB;?
  21. ???unlink?$fileB?if?$fileB?=~?/^d+/;?
  22. ???rename?$fileB,$1?if?$fileB?=~?/^w+_(d+.flv)$/;?
  23. }?
  24. ?
  25. close?DIRB;?

?这个脚本不能体现perl真正的强悍之处 但相比shell来说 做同一件事 perl确实比shell强多了 尤其是在这种文件数目过大 文件过大的情况下?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读