Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Iterating though an array of objects

by Athanasius (Chancellor)
on Aug 27, 2012 at 13:16 UTC ( #989983=note: print w/replies, xml ) Need Help??

in reply to Iterating though an array of objects

Hello rjhill, and welcome to the Monastery!

In addition to the points noted by moritz above, the statement

print "Hash Value : $item->{name}\n";

references a non-existent object member “name”; this should be either

print "Hash Value : $item->{_name}\n";

or (preferably)

print "Hash Value : ", $item->name(), "\n";

The latter is better as it does not break the object’s encapsulation. I suspect this was the syntax you were looking for.

Also, the statement

print "Hash Value : $item->{version}\n";

references an object member “version” which is not declared or initialised in package person.

A final note: It is usual practice to begin the name of a user-defined package with a capital letter: package Person;.

Hope that helps,

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^2: Iterating though an array of objects
by rjhill (Initiate) on Aug 27, 2012 at 13:53 UTC
    Yes, thank you very much. I hope to spend more time here.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989983]
[choroba]: It's just troll feeding.
[beech]: of course the magic word that explains everything :p
[erix]: they should lean to gnash their teeth a bit instead of writing more ^Re:NN-nodes :)
[erix]: *learn

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-01-17 23:46 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (159 votes). Check out past polls.