in reply to bless + tie
This rather defeats the point of OO arch. Presumbably you want to do this:
$obj->{attibute} # instead of $obj->get_attribute();
Which given that most object are just blessed hashes you can do right now.....
package Foo; use Data::Dumper; my $o = new Bar; print $o->get_attribute(), $/; print $o->set_attribute('new val'), $/; print $o->set_flubber('dubber'), $/; print "Direct access, interpolated get flubber = $o->{flubber}\n"; print $o->no_exist(); print Dumper $o; package Bar; sub new{ return bless { attribute => 'value' }, shift } sub AUTOLOAD { my $self = shift; my ( $func ) = $AUTOLOAD =~ m/::([^:]+)$/; if ( $func =~ s/^set_// ) { return $self->{$func} = shift; } elsif ( $func =~ s/^get_// ) { return exists $self->{$func} ? $self->{$func} : undef; } else { my @caller = caller(); warn "Non existant function $func() called by:\n@caller\n"; return 0; } } sub DESTROY{}
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
You missed my point
by cbraga (Pilgrim) on Oct 01, 2003 at 06:13 UTC | |
by tachyon (Chancellor) on Oct 01, 2003 at 06:38 UTC | |
by bsb (Priest) on Oct 01, 2003 at 07:19 UTC |