本帖最后由 leo66888 于 2014-06-25 21:44 编辑
才学perl不久,希望能帮到你
结果是直接输出到屏幕(没重定向到一个文档)
#!perl -w
use strict;
my $fh;
my @a=();
my $txt_out;
my @b;
open $fh,'<','key-zip-removal.txt' or die "Couldn't open the file!!!\n";
while ( my $line = readline $fh ){
chomp $line;
push @a, $line;
}
foreach my $a(@a){
@b = split /,/,$a;
foreach my $b(@b){
$b =~ s{C: \\ .* .zip}{}gx;
$txt_out .="$b,";
}
@b = ();
print $txt_out,"\n";
print "\n";
$txt_out = '';
}
__END__
下面是输出的结果,每行后面会多个"," 希望影响不大 :wink:
"dbid","display_name","Attachments","Description",
"33813948","CQ00259516","C:\1\new\33813948\CI PS Service Group.pdf,C:\1\new\3381
3948\ARME causes.xlsx,C:\1\new\33813948\CI MM Service Group.pdf,C:\1\new\3381394
8\CI CC Service Group.pdf,C:\1\new\33813948\ci_mm.h"," , , , ,ci_mm.h",
"33813950","CQ00259518","C:\1\new\33813950\AT$CCLK.xlsx,,,"," , , , ",
"33813951","CQ00259519","C:\1\new\33813951\CI MM Service Group.pdf,C:\1\new\3381
3951\ci_mm.h,C:\1\new\33813951\13340 51-at-t-spec.pdf,"," ,ci_mm.h ? interface f
ile updated,AT&T spec, ",
"33813952","CQ00259520","C:\1\new\33813952\ci_mm.h,","Updated ci_mm.h file, ",
"33813955","CQ00259523","C:\1\new\33813955\AT&F.xlsx,,,"," , , , ",
"33813956","CQ00259524",",C:\1\new\33813956\AT&S.xlsx"," , ",
"33813958","CQ00259526","C:\1\new\33813958\ATstarALS.xlsx,"," , ",
"33813962","CQ00259530","C:\1\new\33813962\PrefRat_PS441_2.7z,C:\1\new\33813962\
ci_dev.h,"," ,ci_dev.h, ",
"33813963","CQ00259531",""," ",
"33813976","CQ00259544",""," ",
"33813980","CQ00259548",",C:\1\new\33813980\ATstarCHECKEMER.xlsx"," , ",
"33813981","CQ00259549","C:\1\new\33813981\CIIND.docx","1",
"33813983","CQ00259551",""," ",
"33813984","CQ00259552",",C:\1\new\33813984\ATstarCNMA.xlsx"," , ",
"33813985","CQ00259553","C:\1\new\33813985\CNTI fail.txt,C:\1\new\33813985\ci_mm
.h,C:\1\new\33813985\CI MM Service Group.pdf,,C:\1\new\33813985\ATstarCNTI.xlsx"
," ,CI_MM,H, , , ",
"33813986","CQ00259554",",C:\1\new\33813986\ATstarCPBC.xlsx"," , ",
"33813990","CQ00259558",""," ",
"33813991","CQ00259559",",,C:\1\new\33813991\ATstarCSCB.xlsx,"," , , , ",
"33813993","CQ00259561","C:\1\new\33813993\ATstarCSIMSTAT.docx,C:\1\new\33813993
\CI SIM Service Group.pdf,,C:\1\new\33813993\asteriskCSIMSTAT.xlsx"," , , , ",
"33813994","CQ00259562",",C:\1\new\33813994\ATstarDEMERGNCY.xlsx"," , ",
"33814005","CQ00259573","C:\1\new\33814005\ATstarHSPACONFIG.docx,"," , ",
"33814006","CQ00259574",",,,C:\1\new\33814006\ATstarICCID.xlsx,,"," , , , ,ACAT
log from customer with failure - V9, ",
"33814013","CQ00259581","C:\1\new\33814013\MRD system016.pdf,C:\1\new\33814013\A
TstarMRDunderscoreAUTH.xlsx"," , ",
"33814017","CQ00259585","C:\1\new\33814017\MRD system016.pdf,C:\1\new\33814017\A
TstarMRDunderscoreIMEI.xlsx,,,"," , , , , ",
"33814018","CQ00259586",",C:\1\new\33814018\ATstarMRDunderscoreMEP.xlsx"," , ",
"33814028","CQ00259596","C:\1\new\33814028\ATstarRSTMemFullY.xlsx,,"," , , ",
"33814033","CQ00259601",",C:\1\new\33814033\ATstarSIMDETEC.xlsx"," , ",
"33814037","CQ00259605","C:\1\new\33814037\ATstarTGSINK.xlsx"," ",
"33814048","CQ00259616","C:\1\new\33814048\BANSELCT.xlsx,,,,,"," , , , , , ",
"33814049","CQ00259617","C:\1\new\33814049\AT+CACM.xlsx,,"," , , ",
"33814050","CQ00259618","C:\1\new\33814050\AT+CAMM.xlsx"," ",
"33814054","CQ00259622","C:\1\new\33814054\Charger AT commands system requiremen
ts.docx,C:\1\new\33814054\AT+CBC.xlsx,C:\1\new\33814054\CBC_TC4_BUG.icl"," , , "
,
"33814061","CQ00259629","C:\1\new\33814061\AT+CCFC.xlsx,C:\1\new\33814061\Log 15
-Aug-13 09;00;45.icl,,"," , , , ",
"33814062","CQ00259630","C:\1\new\33814062\AT+CCHC.xlsx"," ",
"33814064","CQ00259632",",,,"," , ,version: E2_NA04_0126_C1_DD, ",
"33814065","CQ00259633","C:\1\new\33814065\AT+CCWA.xlsx,C:\1\new\33814065\CCWA_T
C5_BUG.icl"," , ",
"33814066","CQ00259634","C:\1\new\33814066\ts_127007v110500p_AT_commands.pdf","S
ee 13.2.4 for System definition on AT+CDEFMP",
"33814070","CQ00259638","C:\1\new\33814070\ts_127007v110500p_AT_commands.pdf","s
ee 13.2.2 for definition of AT+CDUP", |