in reply to Re: isa() on any scalar
in thread isa() on any scalar
This follows the "if it walks like a duck" paradigm. Not saying that this is the best way to do it, but it works for me.sub parent { my $self = $_[0]; if ( $_[1] ) { my $parent = $_[1]; if ( $parent->can('parent') ) { $self->[PARENT] = $parent; } else { my $ref = ref $self; carp "parents can only be $ref objects"; return; } } return $self->[PARENT]; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: isa() on any scalar
by mrborisguy (Hermit) on Jun 11, 2005 at 21:05 UTC |