Re: code line of the day

2006-09-08 Thread John Douglas Porter
* 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

Re: code line of the day

2006-09-08 Thread John Douglas Porter
A. Pagaltzis [EMAIL PROTECTED] wrote: sub flatten_copy { local $_ = shift; ref $_ eq 'SCALAR' ? $$_ : $_; } my %copy = %$tmpls; $_ = \( flatten_copy $_ ) for values %copy; @{$self-{templates}}{ keys %copy } = values %copy; Excellent! I believe it's

Re: code line of the day

2006-09-08 Thread A. Pagaltzis
* Chris Dolan [EMAIL PROTECTED] [2006-09-08 17:10]: Why did you use local? Shouldn't the following work? sub flatten_copy { my $s = shift; ref $s eq 'SCALAR' ? $$s : $s; } Works the same. I often use `local $_` in tiny functions that mangle just a single value.

local vs. my (was Re: code line of the day)

2006-09-08 Thread Chris Dolan
On Sep 8, 2006, at 6:48 PM, A. Pagaltzis wrote: * Chris Dolan [EMAIL PROTECTED] [2006-09-08 17:10]: Why did you use local? Shouldn't the following work? sub flatten_copy { my $s = shift; ref $s eq 'SCALAR' ? $$s : $s; } Works the same. I often use `local $_` in tiny