Honorable monks!

(EDIT: for a simplified bug-demo see update further down and one-liner post)

For Re: Syntax explanation required I tried to show the elimination of duplicates when assigning a list of two hashes to a third hash.

But while the third hash holds the correct results (line 105) the return value (line 102) of the assignment looks very weird, and I can't really explain whats happening.

DB<100> %h1=(a=>1,b=>2); => ("a", 1, "b", 2) DB<101> %h2=(a=>11,c=>3); => ("a", 11, "c", 3) DB<102> %h=(%h1,%h2) => ("b", 2, "b", 2, "c", 3) DB<103> @ret = ( %h=(%h1,%h2) ) => ("b", 2, "b", 2, "c", 3) DB<104> \@ret => ["b", 2, "b", 2, "c", 3] DB<105> %h => ("c", 3, "a", 11, "b", 2)

to be sure that it's not just my repl showing buggy results I reproduced it again on the console:

> perl %h1=(a=>1,b=>2); %h2=(a=>11,c=>3); print (%h3=(%h1,%h2),"\n"); print %h3; __END__ b2b2c3 c3a11b2

I'm still suffering from a little hangover from recent tumultuous events ... ;-)

So please could someone tell me what I am missing here?

Cheers Rolf

UPDATE:

I was able to further isolate whats happening to a simple list assignment:

DB<107> %h=("a", 1, "b", 2, "c", 3, "a", 11) => ("b", 2, "b", 2, "c", 3) DB<108> %h=("a", 1, "b", 2, "c", 3, "d", 4) => ("a", 1, "b", 2, "c", 3, "d", 4) DB<110> %h=("a", 1, "a", 11, "b", 2) => ("a", 11, "a", 11)

seems like that the fact that duplicated keys are eliminated (here a) somehow confuses the returned value.


In reply to return of hash-assigment in list context (bug?) by LanX

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.