Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Empty multidimentional Array

by gandhit (Initiate)
on Sep 27, 2010 at 14:26 UTC ( [id://862223]=perlquestion: print w/replies, xml ) Need Help??

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

Can anybody please tell me how to empty multidimentional array?

Thanks

Replies are listed 'Best First'.
Re: Empty multidimentional Array
by dasgar (Priest) on Sep 27, 2010 at 14:46 UTC

    Unless you're still wanting data somewhere in the array left alone, undef @multidimensional; will 'empty' out the entire array.

Re: Empty multidimentional Array
by BrowserUk (Patriarch) on Sep 27, 2010 at 14:46 UTC
Re: Empty multidimentional Array
by toolic (Bishop) on Sep 27, 2010 at 14:49 UTC
    If you have an array-of-arrays, this might do it:
    use strict; use warnings; use Data::Dumper; my @aoa = ([1..3], [4..6]); print Dumper(\@aoa); @aoa = (); print Dumper(\@aoa); __END__ $VAR1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; $VAR1 = [];
Re: Empty multidimentional Array
by JavaFan (Canon) on Sep 28, 2010 at 11:37 UTC
    @array = (); $arrayref = [];
    works regardless how many 'dimensions' the arrays have.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://862223]
Approved by lidden
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-28 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found