Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: OO doesn't seem to play nice with multiple instances

by gellyfish (Monsignor)
on Jun 01, 2005 at 21:09 UTC ( [id://462662]=note: print w/replies, xml ) Need Help??


in reply to OO doesn't seem to play nice with multiple instances

I would suggest storing the name in the hash you are using as the object - like with a key such as '_name'. You can then change your methods like:

sub myNameIs{ my ($this,$name) = @_; die("Don't tell me that I don't have a name.") unless(defined($nam +e)); $this->{_name} = $name; } sub whoAmI{ my ($this ) = @_; return($this->{_name}); }
The way that you are using the $_name is like having a static variable in other languages.

/J\

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found