Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: ask about array and hash

by Anonymous Monk
on Jan 17, 2002 at 08:23 UTC ( [id://139440]=note: print w/replies, xml ) Need Help??


in reply to ask about array and hash

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found