The stupid question is the question not asked | |
PerlMonks |
Re: Conditional Map?by seattlejohn (Deacon) |
on Oct 07, 2002 at 14:04 UTC ( [id://203328]=note: print w/replies, xml ) | Need Help?? |
map's best friend is grep, which returns the subset of list elements matching a condition. So you could start by selecting just the array elements you want:
grep {substr($_,0,1) ne 'f'} @array
This returns a list consisting of qw(bar baz bodkin), which should be just what you need for your map: my %hash1 = map {getkey($_) => $_} grep {substr($_,0,1) ne 'f'} @array;
In Section
Seekers of Perl Wisdom
|
|