找到第一个匹配项后我需要退出循环并转到循环中的另一个搜索
use strict;
use warnings;
my %iptv;
sub trim($) {
my $string = shift;
$string =~ s/\r\n//g;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
my @files=</tests/*>;
open IN, "/20131105.csv";
LINE: while (<IN>) {
chomp;
my @result = split(/;/,$_);
my $result1 = trim($_);
$result[1] = trim($result[1]);
$iptv{$result[1]} = $result1;
}
close IN;
foreach my $file (@files) {
open FILE, "$file";
while (<FILE>) {
chomp;
my ($mac, $date) = split(/;/,$_);
my @date1 = split(/\s/, $date);
print "$iptv{$mac};$date1[0]\n" if defined $iptv{$mac};
last LINE if (defined $iptv{$mac});
}
close FILE;
}
我尝试使用“last”功能,但它找到了第一个匹配项并结束程序。我必须放在最后?