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

Re: Array reference problem

by SuicideJunkie (Vicar)
on Jul 07, 2009 at 16:19 UTC ( [id://777927]=note: print w/replies, xml ) Need Help??


in reply to Array reference problem

Why exactly are you not using an array of arrays or a hash of arrays? Strict frowns on the use of such refs for a good reason.

Hash of Arrays example:
my $HoA; $HoA->{CountArray} = [1, 2, 3, 4]; my @AlphaArray = ('a', 'b', 'c', 'd'); $HoA->{AlphaArray} = \@AlphaArray; DoStuff($HoA, 'AlphaArray'); sub DoStuff { my $HoA = shift; my $desiredArrayName = shift; die "There is no such thing as '$desiredArrayName'" unless exists ($ +HoA->{$desiredArrayName}); foreach my $value (@{$HoA->{$desiredArrayName}}) { print "$value\n"; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-06-16 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.