In the Perl documentation (perlintro) it says that you can find out the number of elements in an array using the following syntax:
print $myvar[$#mmyvar]; I am running into a problem when I try to find the number of elements in an array that is being returned from an object. I am using XML::Simple to parse an XML document, and have the following snippet of code giving me trouble: print $#xml->{'channel'}; for ($i=0; $i <= $#xml->{'channel'}; $i++) { print $xml->{'channel'}[$i]; } It bombs on the very first line of the snippet with an error "Use of unitialized value in print..." If I take the '#' out and just run: print $xml->{'channel'}; I get "ARRAY(0x84711a4)" as output. This would lead me to believe that I am indeed passing an initialized array to the print function...? I have been diging through the documentation and various websites for literally 6 hours now. I'm beginning to suspect I may be missing something extremely obvious (making myself look like an idiot) or that maybe it has something to do with the way Perl handles references...? Does anyone have any suggestions or pointers? Thanks for your time. -- Aaron C. de Bruyn [EMAIL PROTECTED] .-. /v\ L I N U X // \\ >Penguin Power< /( )\ ^^-^^ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>