perl批量处理
和我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$/;
[*] printf "%s\n",$fileA;
[*] #perl 如何调用系统命令 我主要就是想知道这个的
[*] system "yamdi -i $fileA -o tmp_$fileA -c 'modify by mytv365.com'";
[*]}
[*]
[*]close DIRA;
[*]
[*]opendir DIRB,'/opt/test/20111201_import' or die "$!\n";
[*]
[*]while (my $fileB = readdir DIRB) {
[*] chomp $fileB;
[*] unlink $fileB if $fileB =~ /^\d+/;
[*] rename $fileB,$1 if $fileB =~ /^\w+_(\d+\.flv)$/;
[*]}
[*]
[*]close DIRB;
这个脚本不能体现perl真正的强悍之处 但相比shell来说 做同一件事 perl确实比shell强多了 尤其是在这种文件数目过大 文件过大的情况下
页:
[1]