Yes, that works in most other languages. In ruby, arr[0..-1] returns all elements of the array (and is an lvalue too). In python, arr[0:-1] is all but the last element, arr[0:] or arr[:] is all elements. In octave, you don't have negative array indexes, but you have avec(:) for all of the vector, but also no special notation for all the elements starting the n'th (like arr[n:] in python). In mathematica, you have arr[[All]] for all elements of the array, but also no starting slice notation. (These are only a few languages of course.)

Anyway, you can write 0..$#_ or even 0..@_ as the index, or avoid indexing completely and say sub undeff { undef $_ for @_ }.


In reply to Re^3: undef a List of Variables by ambrus
in thread undef a List of Variables by Dr. Mu

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.