关于perl从文件中查找特定字符串:

2025-05-09 05:04:40
推荐回答(1个)
回答1:

while ($str = ) {
my @p = (0xFFFFFFFF, 0xFFFFFFFF);
my $i = 0;
while ($str =~ /(\w+)/g) {
if ($1 eq 'decision')    {$p[0] = $i; if (abs($p[0] - $p[1]) <= 6){print "matched\n"; last;}}
elsif ($1 eq 'McMillon') {$p[1] = $i; if (abs($p[0] - $p[1]) <= 6){print "matched\n"; last;}}
$i++;
}
}
__DATA__
Walmart chief executive Douglas McMillon defends company's decision to invest billions in improving its stores and Internet shopping presence。