in reply to Re^3: use 'local' modifier to hashref element
in thread use 'local' modifier to hashref element
Interestingly, the code:
complains that you "Can't localize lexical variable @array", but it has no problem localizing $hash{foo}.#!/usr/bin/perl use warnings; use strict; my %hash; my @array; { local $hash{foo} = 'bar'; local @array; }
Even more interestingly, the code:
shows that the localization of the hash slot does _not_ manipulate the symbol table--even without "use strict".#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %hash; our @array; { local $hash{foo} = 'bar'; local @array; print Dumper(\%main::); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: use 'local' modifier to hashref element
by shmem (Chancellor) on Jun 06, 2013 at 13:56 UTC | |
Re^5: use 'local' modifier to hashref element
by jakeease (Friar) on Jun 06, 2013 at 08:07 UTC |
In Section
Seekers of Perl Wisdom