is not a sub. sleep
is a buildin. In this, it makes all the difference. Subs have @_
, and their arguments are aliased to it. Hence the lvalue of arguments to subs - but not to buildins (with a few exceptions).
Be that as it may, where can I learn more about this sub-args-as-lvalues thing? I can't find documentation for it.
Very early in man perlsub
, as soon as it starts talking about @_
. The third paragraph of the description:
Any arguments passed in show up in the array @_. There
fore, if you called a function with two arguments, those
would be stored in $_ and $_. The array @_ is a
local array, but its elements are aliases for the actual
scalar parameters. In particular, if an element $_ is
updated, the corresponding argument is updated (or an
error occurs if it is not updatable). If an argument is
an array or hash element which did not exist when the
function was called, that element is created only when
(and if) it is modified or a reference to it is taken.
(Some earlier versions of Perl created the element whether
or not the element was assigned to.) Assigning to the
whole array @_ removes that aliasing, and does not update
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||