1
#!C:\Perl\bin\perl.exe
use strict;
use warnings;
use Data::Dumper;
my $fh = \*DATA;
while(my $line = <$fh>)
{
$line =~ s/ ^/male /x ;
print $line ;
}
__DATA__
1 0104 Mike Lee 2:01:48
male 1 0104 Mike Lee 2:01:48
然後我試圖插入男性後racenumber(0104),I與風格替換的代碼。
$line =~ s/ ^\d+\s+\d+\s+ /male /x ; # but failed
Acturally我想要的輸出。謝謝。
1 0104 male Mike Lee 2:01:48
@toolic。感謝您的**一美元**。我google了一下,發現這個'http:// stackoverflow.com/questions/1036285/what-does-1-mean-in-perl' – 2010-04-27 23:20:49
我用另一個鏈接更新了我的答案,描述了$ 1。 – toolic 2010-04-27 23:27:14