Usually I try to pop the elements as I use them, so there's no additional cleanup needed in the end, or if it's at the end of the script, there's not really a need to manually delete it. Here's the script I was writing, where I was needing it.

while (<infp>) { if (/^%!PS-Adobe/) #Start of Page Marker { if ($found_match) { @linelist = reverse @linelist; while ($line = pop(@linelist)) { print $line; } $found_match = 0; } else { #Empty List undef @linelist; } } elsif(/^%%Title/) { for $z(@figlist) { if (/$z[A-Za-z]*\.eps/i) { $found_match = 1; } } } push @linelist, $_; }

Basically it parse a PostScript file, ripping out only the pages that match a certain search criteria (@figlist)

I guess a different design would have prevented the need to delete the list. I never really used the "strict" keyword, but I'm glad you brought it up, it does help enforce good coding.

Thanks for your response!


In reply to Re: Re: Elegant way of destroying a list by JojoLinkyBob
in thread Elegant way of destroying a list by JojoLinkyBob

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.