in reply to comparing values between two arrays
The grep test starts being true when the item is found in the hash, and also stops being true with the same test. But it won't test the stop condition on the same round as the start condition! That's why the three dots. With only two dots, it would have found the stop condition on the same item.my @numbers = ('25', '12', '32','56','45','21','65'); my @needed = ('25','32','45','65'); my %needed_hash = map { $_ => 1 } @needed; my @result = grep { $needed_hash{$_} ... $needed_hash{$_} } @numbers; print "@result\n";
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|