Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Syntax for partly associative arrays

by fletcher_the_dog (Friar)
on Sep 05, 2003 at 21:04 UTC ( [id://289350]=note: print w/replies, xml ) Need Help??


in reply to Re: Syntax for partly associative arrays
in thread Syntax for partly associative arrays

Just to add to what Zaxo said, you'll probably want to use an explicit aliasing variable in your 'for' loops instead of $_ for clarities sake. Something like this:
foreach my $hash (@a) { foreach my $word (keys %$hash) { my $wordvalue = $hash->{$word}; # ... } }
Notice that because $hash is a reference to a hash you access its elements via ->{}. In general if you are going to iterate through an array, you want to use 'foreach's aliasing ability to access the elements of the array directly instead of accessing the elements through their indexes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found