Fellow Monks,

Recently there was a post on array refs that had a follow-up stating you could force a list into array context using @{[ &make_list_here ]}. This isn't what i'm doing. But it relates...

A general warning, yes, i could use Parse::RecDescent, but i'm still trying to do some things the hard way to learn why other things work the way they do.

So i'm parsing a file and most of the data is flat, but there are sometimes when i want to get a hash out of the data. So the code i use is:

# this is in a loop that iterates through the file # and at some point it runs across: /(\S+)\s?=?\s?\[(.+)\]$/ && do { $hash{$1} = split /,/, $2; next; };

This works, but with warnings i got the message:
Use of implicit split to @_ is deprecated
Looking this up it says i was assigning to @_, but it doesn't look like that at all to me. That looks like assingment to a hash entry as an anonymous list. When i apply the context generating code above like so:
/(\S+)\s?=?\s?\[(.+)\]$/ && do { $hash{$1} = @{[ split /,/, $2 ]}; next; };
the error message goes away. i'm glad the message is gone, but i'm wondering why it gave that error message (which seems inappropriate) and why this fixed it.

please enlighten this quandering quaffer of quintessential qualms (or not ; )

jynx


In reply to list vs array context: odd error message... by jynx

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.