perlquestion
bobtfish
Why does this return the same value from both objects?
<CODE>
$baz=TESTME->new();
$foo=$baz->wibble();
warn "Foo is $foo";
sleep 5;
$bar=$baz->wibble();
warn "Bar is $bar";
warn "Foo is $foo";
print $foo->get();
print $bar->get();
print "\n";
exit;
package TESTME;
sub new {
my $class = shift;
my $self = {};
bless ($self, $class);
warn "In TESTME->new, created object $self in class $class";
return $self;
}
sub wibble {
my $self = shift;
my $val = shift;
my $object = undef;
$object=TEST->new ;
warn "In wibble, object $self val $val created object $object";
return $object;
}
package TEST;
sub new {
my $class = shift;
my $self = {};
bless ($self, $class);
$self{'date'} = `date`;
warn "In TEST->new, created object $self, with date $self{'date'}";
return $self;
}
sub get {
my $self = shift;
warn "In TEST->get with object $self and date $self{'date'}";
return($self{'date'});
}
</CODE>
I am really confused by it..