webby has asked for the wisdom of the Perl Monks concerning the following question:
where persistB.obj is simply a pre-built instance of class B:#!/usr/bin/perl package a; my $bar = 'bar'; sub foo { my $self = shift; @_ ? $bar = shift: $bar; } package b; use base 'a'; sub new { my $class = shift; my $self = bless {}, ref($class)||$class; $self->foo('cow'); return $self; } package main; my $object = do "persistB.obj"; print $object->foo();
then the call to $object->foo() return 'bar', instead of the intended 'cow'.$VAR1 = bless( {}, 'b' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Persistent Class data
by PodMaster (Abbot) on Oct 13, 2002 at 09:10 UTC | |
by webby (Acolyte) on Oct 13, 2002 at 09:24 UTC | |
by webby (Acolyte) on Oct 13, 2002 at 09:59 UTC |