Syntactic Confectionery Delight | |
PerlMonks |
Re: ask about array and hashby Anonymous Monk |
on Jan 17, 2002 at 08:23 UTC ( [id://139440]=note: print w/replies, xml ) | Need Help?? |
References have to be dereferenced to print or iterate through. Your code was attempting to access an element of the list (array) instead of the entire array. To access a single element of a referenced array you can: print ${$entry->FTs->elements}[$number]Make sure you use 'use strict' it would have thrown an error when the example you gave was used, I am not saying it would be any clearer as to how to solve it but at least you would have a starting point :^) For an array reference you would iterate as: print "$_\n" for @{$entry->FTs->elements};for a hash ref: print "$_ = $hashref->{$_}\n" for keys %{$hashref}; See 'perldoc perlref' for more information. or on the web at: perlref
In Section
Seekers of Perl Wisdom
|
|