问题是它像未定义值上的拆分一样返回
B
e
c
k
y
.
拆分字符串 perl 代码
sub start_thread {
my @args = @_;
print('Thread started: ', @args, "\n");
open(my $myhandle,'<',@args) or die "unable to open file"; # typical open call
my @aftersplit;
for (;;) {
while (<$myhandle>) {
chomp;
@aftersplit = split('|',$_);
#print $_."\n";
foreach my $val (@aftersplit){
print $val."\n";
}
}
sleep 1;
seek FH, 0, 1; # this clears the eof flag on FH
}
}
它将字符串拆分为 $_ 并在拆分后保存在数组中