in reply to comparing
Here is something that works:
my @file1 = qw(22-28 36 44-49 234 77 26); my @file2 = qw(23 11 21 44 233 26); my %wanted = (); foreach my $num (@file1) { if ($num =~ /^(\d+)-(\d+)$/) { $wanted{$_}++ for $1 .. $2; } else { $wanted{$num}++; } } foreach (@file2) { print $_, "\n" if $wanted{$_}; } __END__ Output: 23 44 26
gav^
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: comparing
by DS (Acolyte) on Jul 22, 2002 at 13:45 UTC |