目录中文件内容处理小工具

    技术2022-05-20  68

    #!perl -w use strict; my @DatFileNames = glob "*.dat"; print @DatFileNames; my $FileHandle; my $OutPutFileHandle; my $FileName; $^I = ".bak"; mkdir "back"; foreach $FileName (@DatFileNames) { open $FileHandle,"<",$FileName or die "can't open file($!)/n"; open $OutPutFileHandle,">",".//back//".$FileName or die "can't open file($!)/n"; while(<$FileHandle>) { $_ =~ s/(/d+)(/s*)/n$/-$1/n/; print $OutPutFileHandle $_; } close $FileHandle; close $OutPutFileHandle; }

     

     

    其中$^I  对while  <> {print} 其作用,类似perl -i -e ;

    在此处不起作用了


    最新回复(0)