\@bex won't work unless you do my @bex in the foreach loop. You mentioned this (in less explicit terms), but I just wanted to be clear.
The scoping doesn't have to be my, local works just fine too:
#! perl -slw
use strict;
use Data::Dumper::SLC;
my %hash;
our @array;
for my $i ( 0 .. 9 ) {
local @array = map{ "$i : $_" } 1 .. 5;
$hash{ $i } = \@array;
}
Dump \%hash, 60;
__END__
c:\Perl\test>junk3
{
0 => [ '0 : 1', '0 : 2', '0 : 3', '0 : 4', '0 : 5', ],
1 => [ '1 : 1', '1 : 2', '1 : 3', '1 : 4', '1 : 5', ],
2 => [ '2 : 1', '2 : 2', '2 : 3', '2 : 4', '2 : 5', ],
3 => [ '3 : 1', '3 : 2', '3 : 3', '3 : 4', '3 : 5', ],
4 => [ '4 : 1', '4 : 2', '4 : 3', '4 : 4', '4 : 5', ],
5 => [ '5 : 1', '5 : 2', '5 : 3', '5 : 4', '5 : 5', ],
6 => [ '6 : 1', '6 : 2', '6 : 3', '6 : 4', '6 : 5', ],
7 => [ '7 : 1', '7 : 2', '7 : 3', '7 : 4', '7 : 5', ],
8 => [ '8 : 1', '8 : 2', '8 : 3', '8 : 4', '8 : 5', ],
9 => [ '9 : 1', '9 : 2', '9 : 3', '9 : 4', '9 : 5', ],
}
The funny thing is that I changed the wording specifically to avoid a correction being required :)
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|