I am really confused by it..$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'}); }
In reply to Why, when my object creates another object and passes it back, does it not work? by bobtfish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |