\@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.

In reply to Re^4: Hash problem by BrowserUk
in thread Hash problem by Gnat53

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.