Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Printing reference

by TomDLux (Vicar)
on Sep 27, 2010 at 16:27 UTC ( [id://862240]=note: print w/replies, xml ) Need Help??


in reply to Printing reference

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.

Log In?
Username:
Password:

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

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

    No recent polls found