Re: code line of the day

John Douglas Porter <[email protected]> Fri, 8 Sep 2006 06:36:23 -0700 (PDT)
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
> * Uri Guttman <[email protected]> [2006-09-07 09:30]:
> > 
> > 	@{$self->{templates}}{ keys %{$tmpls} } =
> > 		map ref $_ eq 'SCALAR' ? \"${$_}" : \"$_", values %{$tmpls} ;


If we're looking for ways to do it differently, possibly better:

my %copy = %$tmpls;
$_ = ref $_ ? \"$$_" : \"$_" for values %copy;
@{$self->{templates}}{ keys %copy } = values %copy;

Three statements vs 1, and a temporary variable...
I'm not sure that's better either.  Maybe clearer.

-- 
John Douglas Porter


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com