和我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 "%s\n",$fileA; 
  11.    #perl 如何调用系统命令 我主要就是想知道这个的
  12. system "yamdi -i $fileA -o tmp_$fileA -c 'modify by mytv365.com'";  
  13.  
  14. close DIRA; 
  15.  
  16. opendir DIRB,'/opt/test/20111201_import' or die "$!\n"; 
  17.  
  18. while (my $fileB = readdir DIRB) { 
  19.    chomp $fileB; 
  20.    unlink $fileB if $fileB =~ /^\d+/; 
  21.    rename $fileB,$1 if $fileB =~ /^\w+_(\d+\.flv)$/; 
  22.  
  23. close DIRB; 

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