'It seems to work without the "\".'

That seemed odd to me so I checked it. I modified the output slightly for ease of comparison.

With \:

$ perl -Mstrict -Mwarnings -E ' my %A = (a => 1, b => 2, D => 3); my %Z = (z => 9, y => 8, D => 7); (\ my %all_keys)->@{keys %A, keys %Z} = (); say for "@{[sort keys %all_keys]}"; ' D a b y z

Without \:

$ perl -Mstrict -Mwarnings -E ' my %A = (a => 1, b => 2, D => 3); my %Z = (z => 9, y => 8, D => 7); (my %all_keys)->@{keys %A, keys %Z} = (); say for "@{[sort keys %all_keys]}"; ' D a b y z

So I can confirm that behaviour. I then ran both of those through B::Deparse.

With \:

$ perl -Mstrict -Mwarnings -MO=Deparse -E ' my %A = (a => 1, b => 2, D => 3); my %Z = (z => 9, y => 8, D => 7); (\ my %all_keys)->@{keys %A, keys %Z} = (); say for "@{[sort keys %all_keys]}"; ' use warnings; use strict; use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'isa', 'modul +e_true', 'postderef_qq', 'say', 'signatures', 'state', 'unicode_strin +gs', 'unicode_eval'; my(%A) = ('a', 1, 'b', 2, 'D', 3); my(%Z) = ('z', 9, 'y', 8, 'D', 7); @(\my %all_keys){keys %A, keys %Z} = (); say $_ foreach (join $", @{[sort(keys %all_keys)];}); -e syntax OK

No huge surprises there.

Without \:

$ perl -Mstrict -Mwarnings -MO=Deparse -E ' my %A = (a => 1, b => 2, D => 3); my %Z = (z => 9, y => 8, D => 7); (my %all_keys)->@{keys %A, keys %Z} = (); say for "@{[sort keys %all_keys]}"; ' use warnings; use strict; use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'isa', 'modul +e_true', 'postderef_qq', 'say', 'signatures', 'state', 'unicode_strin +gs', 'unicode_eval'; my(%A) = ('a', 1, 'b', 2, 'D', 3); my(%Z) = ('z', 9, 'y', 8, 'D', 7); @all_keys{keys %A, keys %Z} = (); say $_ foreach (join $", @{[sort(keys %all_keys)];}); -e syntax OK

The lexical variable my %all_keys appears to have been changed in favour of the package variable %all_keys (no my). A search through perlref provided no answers; although, it's not impossible that I missed something. I don't have time to investigate further; perhaps another monk can shed some light on this.

All of the above used:

$ perl -v | head -2 | tail -1 This is perl 5, version 39, subversion 3 (v5.39.3) built for cygwin-th +read-multi

I repeated everything with the earliest Perl version I have available:

$ perl -v | head -2 | tail -1 This is perl 5, version 30, subversion 0 (v5.30.0) built for cygwin-th +read-multi

The results were the same except the "use feature" list was slightly different: signatures out; switch in.

use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'postderef_qq +', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';

I don't believe that difference has any relevance to what's being tested.

— Ken


In reply to Re^4: Problem combining hashes by kcott
in thread Problem combining hashes by jh

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.