Yesterday I had the occasion to write,
undef ($from, $to) if $from > $to
It seemed like a reasonable thing to do. But apparently I had never tried it or had simply forgotten that, "The undef function is a unary operator, not a list operator, so you can only undefine one thing at a time." (Camel Book) So, I settled for the less elegant (in my mind),
$from = $to = undef if $from > $to
But I got to thinking, what would have been so bad about allowing undef to undefine a list of variables? I'm hard-pressed to think of any inconsistencies or ambiguities that might crop up if such a construct were allowed. After all, my can declare a list of variables. It seems logical that if you wanted to wipe that same list clean later, a parallel construction would be a clear and handy thing to have.

So, any ideas why this limitation exists in Perl?

20050201 Considered: holli: move to meditations, unconsidered by Corion: 13/19/0 - no decision


In reply to 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.