As other have explained, it's a one element slice. Unfortunally, if you use it like this, Perl will issue a
warning. I don't think it's right that Perl should give
this warning; why should a one element slice trigger a
warning when two, three, four, ..., or even a zero element
slice don't? Furthermore, in most cases
@foo 1
is used in rvalue context, where it won't matter anyway.
The only place where it might go wrong, is where you use
@foo 1 in lvalue context,
and the RHS of the assignment returns different things in
list and scalar context.
But that's a rare case. In a more common case, which more
often goes wrong is my ($foo) vs my $foo.
But Perl doesn't warn there.
And considering that in perl6, @foo 1 is the
right way to address a single element (what's perl6 syntax
for a one element slice?), I think that warning ought to
removed from Perl.
I've once send that in as a wish to p5p, but it was ignored.
Abigail
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.