[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] hasheesh



On Thu, Mar 29, 2001 at 12:03:10PM -0500, Jeff Pinyan wrote:
> On Mar 29, Casey West said:
> 
> >I use something like this:
> >
> >map {
> >     # processing here
> >     print "$_->[0] => $_->[1]\n"
> >    } map { [ each %ENV ] } keys %ENV;
> 
> Ouch.  You just created a list of the keys in %ENV for no good
> reason.  Why not do:
> 
>   map { ... } map { [ $_ => $ENV{$_} ] } keys %ENV;
> 
> if you're going to use keys %ENV.  Or, use it in the scalar context:
> 
>   map { ... } map { [ each %ENV ] } 1 .. keys %ENV;
> 
> But map() in void context is evil. ;)
> 

Two maps in a row is unnecessary.

map { local $_ = [ $_ => ENV{$_} ]; ... } keys %ENV;

Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe