in reply to hashes: testing for the presence of a key
You could reduce the above to this:for ( @array ) { if ( exists $hash{$_} ) { push @found, $_ . $hash{$_}; } }
Or evenpush @found, map { $_ . $hash{$_} } grep { exists $hash{$_} } @array;
push @found, map { exists $hash{$_} ? $_ . $hash{$_} : () } @array;
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: hashes: testing for the presence of a key
by BrowserUk (Patriarch) on May 15, 2003 at 14:20 UTC |