With reference only to the first part of your OPed question, I agree with Laurent_R's explanations here and here.

Here's another way to think about the issue that might offer some confidence and comfort, for all it's long-windedness. (I don't doubt that you understand all this perfectly well, but perhaps someone else may benefit from this blatheration.) With reference to the OPed code:

Looking at the differing reference addresses of the various storage locations created by your original code example may also be convincing:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "print 'perl version: ', $]; ;; our %h; ;; my $x = do { local %h=(a=>'3'); \%h }; my $y = do { local %h=(b=>'5'); \%h }; ;; print 'ref. addr. of %h: ', \%h; dd 'contents of %h: ', \%h; ;; print 'ref. addr. of $x: ', $x; dd 'contents of $x: ', $x; ;; print 'ref. addr. of $y: ', $y; dd 'contents of $y: ', $y; " perl version: 5.008009 ref. addr. of %h: HASH(0x2c068a4) ("contents of %h: ", {}) ref. addr. of $x: HASH(0x14b5fa4) ("contents of \$x: ", { a => 3 }) ref. addr. of $y: HASH(0x14b60dc) ("contents of \$y: ", { b => 5 })
(Note that this example was run under Perl 5.8.9.)

... I'm wondering if it's "safe" ...

Yes, Dr. Szell, it's perfectly safe.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Referencing localized variables, and typeglobs by AnomalousMonk
in thread Referencing localized variables, and typeglobs by haukex

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.