文件名test内容如下:
one:two
three:four
five:six
要求把它们的结果变为:
two:one
four:three
six:five
源码如下:
#!/usr/bin/perl
open (FILE,"test2");
while(<FILE>) {
($one,$two)=split(/:/);
($a,$b)=($two,$one);
chomp($a);
chomp($b);
printf "$a:$b/n";
}
close(FILE);