Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Printing reference

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

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

I am passing reference of an multidimentional array from one subroutine to another.

I want to print multidimentional array in second subroutine. Can anybody Help me with it?

Replies are listed 'Best First'.
Re: Printing reference
by toolic (Bishop) on Sep 27, 2010 at 15:40 UTC
Re: Printing reference
by TomDLux (Vicar) on Sep 27, 2010 at 16:27 UTC

    You showed no effort on your part. What have you tried and found not to work?

    sub process { my ( $ref ) = @_; for my $row ( @$ref ) { for my $elem( @$row ) { print "'$elem' "; } print "\n"; } } my @data = ( [ qw( a b c d e) ], [ qw( L M N ) ], [ qw( 3 1 4 1 5 9 2 6 ) ], ); process \@data;

    Perl Best Practices recommends using brackets when conjoining sigils ... @{ $ref } ... which I agree with when the expression is at all complicated. When it is as simple as in this case, however, I think it's straightforward enough -> The data stored in $ref is really an array, so please iterate over the elements.

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Re: Printing reference
by planetscape (Chancellor) on Sep 28, 2010 at 12:09 UTC

Log In?
Username:
Password:

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

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

    No recent polls found