my accepts a single variable or a list of variables as argument(s), not array elements or slices.
Yes, but is it really a function, or does it just appear to behave like a function when you look at it sideways? (It does have a return value, but that's usually thrown away -- and does it behave the same way every time?)

Since my has both compile-time and run-time aspects, it's more of a convenience that you can actually do things like

my $x = 42;
If Perl were instead a little stricter in partitioning compile actions vs. execution, then my might be defined as a compiler directive:
my $x; my ($y,@z);
It's intentional laziness that we can initialize these variable declarations in the same statement. Even more so when non-constants like this work:
my @args = @_; my $x = $x; my @results = `some | funky | shell | result`;
We run into problems with my and its cousins because they gloss over some of the bookkeeping and other administrivia that we normally don't care to keep up with. When we try and make them do more work than they can, we find feechers that don't DWIM.

-QM
--
Quantum Mechanics: The dreams stuff is made of


In reply to Re^2: Using an undefined value as a hashref by QM
in thread Using an undefined value as a hashref by talexb

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.