in reply to Array of Hashes
In addition to what trizen said regarding not using prototypes, it is better practice to declare/define your variables as tightly as you can (ie. within the scope you use them if possible). In your case, you can remove the $href and $role declarations by writing the block like this:
for my $href ( @AoH ) { print "{ "; for my $role ( keys %$href ) { print "$role=$href->{$role} "; } print "}\n"; }
Update: This way, anyone looking at your code in the future won't be left wondering if you are reusing those variables later on in the code beyond the nested for loop.
Update: For future reference, also see: How do I post a question effectively?
|
|---|