jimbend has asked for the wisdom of the Perl Monks concerning the following question:
Good day -
I am creating two instances of package Cluster defined below. I thought that the output of the following would yield 'One One'.......but I'm getting..'One Two'. Can someone point out the error of my ways and how to correct this? Many thanks!$test1 = Cluster->new("One"); print $test1->getClusterName()." "; $test2 = Cluster->new("Two"); print $test1->getClusterName();
package Cluster; sub new { my $class = shift; my $self = {}; $self{_clusterName} = shift; $self{_verbs} = []; bless $self, $class; return $self; } sub getClusterName { my( $self ) = @_; return $self{_clusterName}; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Losing a reference to a package instantiation
by ikegami (Patriarch) on Jan 01, 2010 at 23:23 UTC | |
|
Re: Losing a reference to a package instantiation
by Corion (Patriarch) on Jan 01, 2010 at 23:25 UTC | |
|
Re: Losing a reference to a package instantiation
by biohisham (Priest) on Jan 01, 2010 at 23:46 UTC |