George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:
and I want to make a hash using all but words beginning in 'f' as values,my @array = qw/ foo bar baz bodkin /;
works, but is there an equivalent usage with map?my %hash2 = (); foreach $_ (@array) { $hash2{getkey($_)} = $_ unless /^f/; }
doesn't work.my %hash1 = map {getkey($_) => $_ unless /^f/} @array;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conditional Map?
by broquaint (Abbot) on Oct 07, 2002 at 11:33 UTC | |
|
Re: Conditional Map?
by blakem (Monsignor) on Oct 07, 2002 at 11:45 UTC | |
|
Re: Conditional Map?
by seattlejohn (Deacon) on Oct 07, 2002 at 14:04 UTC |