Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to print the deep content of the array?

by ton (Friar)
on Apr 05, 2001 at 03:35 UTC ( [id://69944]=note: print w/replies, xml ) Need Help??


in reply to How to print the deep content of the array?

Of course it's more fun to do it yourself. Try this:
my @ary = (1, ['a', 'b', [], [3, [0], 5]]); print_deep_array(\@ary); print "\n"; sub print_deep_array($) { my $arrRef = shift; for (my $i = 0; $i < scalar(@$arrRef); ++$i) { if (ref($arrRef->[$i]) eq 'ARRAY') { print ', ' if ($i); print '['; print_deep_array($arrRef->[$i]); print ']'; } else { print ', ' if ($i); print $arrRef->[$i]; } } print ' ' if (!scalar(@$arrRef)); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found