Khatri has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, I've wasted my lots of time to create formate throught which I could just dump into dumper so I can print it in good format and yes, it was successfully acomplished but now when I print it repeatedly, it print with the previous results. Basically, I wasn't able to remove whatever I had dumped before.
use Data::Dumper; $k = &Dumper(@somearray);
Thanks monks.

Replies are listed 'Best First'.
Re: how to remove dumped data, dumped using &Dumper()
by duff (Parson) on Nov 03, 2005 at 22:05 UTC

    I don't quite get what your question is, but I'll guess that you're asking how to empty an array:

    @array = ();
    Or if you're in a loop you can just rely on redeclaration:
    while (1) { my @array; ... Dumper(\@array) }
Re: how to remove dumped data, dumped using &Dumper()
by GrandFather (Saint) on Nov 03, 2005 at 22:26 UTC

    In this context (&Dumper(@somearray);) & is not required and is normally not used.

    Note too that Dumper(\@somearray); generally gets you better output. (see sample below).

    Note that your sample code doesn't actually demonstrate a problem. duff has given an answer that probably answers your question, but not by carefull examination of your sample code or its output. In general something like the following will get you better answers sooner:

    use strict; use warnings; use Data::Dumper; my @somearray = (['1', 2], ['3', 4]); print "Unreffed:\n" . Dumper (@somearray) . "\n"; print "Reffed:\n" . Dumper (\@somearray) . "\n"; push @somearray, (['5', 6], ['7', 8]); print Dumper (\@somearray) . "\n"; @somearray = (['9', 10], ['11', 12]); print Dumper (\@somearray) . "\n";

    Prints:

    Unreffed: $VAR1 = [ '1', 2 ]; $VAR2 = [ '3', 4 ]; Reffed: $VAR1 = [ [ '1', 2 ], [ '3', 4 ] ]; $VAR1 = [ [ '1', 2 ], [ '3', 4 ], [ '5', 6 ], [ '7', 8 ] ]; $VAR1 = [ [ '9', 10 ], [ '11', 12 ] ];

    Perl is Huffman encoded by design.
Re: how to remove dumped data, dumped using &Dumper()
by kirbyk (Friar) on Nov 03, 2005 at 22:27 UTC
    I think it's not a question, it's sharing a tip, just worded a little strangely. :-)

    -- Kirby, WhitePages.com

      In which case it should be in Snippets. Maybe OP will clarify the issue in due course.


      Perl is Huffman encoded by design.