note
nothingmuch
Yes, slices are awesome.
<p>
Another little known feature of hash slices is that they are localizable:
<c>
use Data::Dumper;
my %hash = ( foo => 1, bar => 2 );
warn Dumper(\%hash);
{
local @hash{qw/bar moose/} = qw/happy joy/;
warn Dumper(\%hash);
}
warn Dumper(\%hash);
__END__
$VAR1 = {
'bar' => 2,
'foo' => 1
};
$VAR1 = {
'bar' => 'happy',
'moose' => 'joy',
'foo' => 1
};
$VAR1 = {
'bar' => 2,
'foo' => 1
};
</c>
<div class="pmsig"><div class="pmsig-205152">
-nuffin<br>zz zZ Z Z #!perl
</div></div>
570036
570181