* 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
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
* 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.
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