undef takes a scalar, not a list. (see perldoc -f undef)

use strict; use warnings; my %hash = ( foo => 'bar' ); my @index = qw( baz bong ); my @a2 = qw( a b c ); undef %hash, @index, @a2; print %hash, @index, @a2; __END__ # prints -> baz bong a b c

When I do this with warnings on, though, I get "Useless use of private array in void context" warnings, since the remainder of that expression does nothing with the variables. You should be seeing those too, no?

Rather than depending on yourself to clear out values at the top of each loop, I strongly recommend just making them lexicals, and use strict. You avoid this whole class of bugs.

Additionally, I am not sure what %hash and @index are doing in there. You populate them, then don't use them, then clear them.


In reply to Re: Why output is appending in each file?? by fishbot_v2
in thread What is the problem with this script as no output by cybersmithuk

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.