Perl_分割字符串_split(/\t/,$_,4)
cat file1
A\t2\t7\tD
B\t4\t2\tC
D\t2\t4\tE
例
open IN,"/ifs1/ST_MED/USER/oumin/test/file1" or die ;
while(<IN>)
{
chomp;
my @array=split(/\t/,4);
foreach (@array)
{
print $_."!!!";
}
print "\n";
}
A!!!2!!!7!!!D!!!
B!!!4!!!2!!!C!!!
D!!!2!!!4!!!E!!!
例
open IN,2); #把上面的4改成2
foreach (@array)
{
print $_."!!!";
}
print "\n";
}
A!!!2\t7\tD!!!
B!!!4\t2\tC!!!
D!!!2\t4\tE!!!
例
open IN,3); #把上面的4改成3 foreach (@array) { print $_."!!!"; } print "\n"; } A!!!2!!!7\tD!!! B!!!4!!!2\tC!!! D!!!2!!!4\tE!!!