metcals1 has asked for the wisdom of the Perl Monks concerning the following question:
sub AUTOLOAD { my $self = shift; my $type = ref($self) || $self; return if $AUTOLOAD =~ /::DESTROY$/; my $name = $AUTOLOAD; $name =~ s/.*://; my $dbh = BSN::DB::connect(); my $sql = "select * from method_tbl where name='".$name."' and typ +e='".$self->{_type}."'"; my $sth = $dbh->prepare($sql); $sth->execute(); my $ref = $sth->fetchrow_hashref(); unless (exists $ref->{body}) { $sql = "select * from method_tbl where name='".$name."' and ty +pe='Default'"; $sth = $dbh->prepare($sql); $sth->execute(); $ref = $sth->fetchrow_hashref(); unless (exists $ref->{body}) { return "Can't access `$name' method in class ".$self->{_ty +pe}; } } my $call = eval("$ref->{body}"); if ($@) { croak "Method Error: $@ in method `$name' in class $type"; } unshift @_,$self; goto &$call; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: AUTOLOAD detecting the type of method call.
by MZSanford (Curate) on Sep 20, 2001 at 12:53 UTC | |
|
Re (tilly) 1: AUTOLOAD detecting the type of method call.
by tilly (Archbishop) on Sep 20, 2001 at 16:25 UTC | |
|
Re: AUTOLOAD detecting the type of method call.
by perrin (Chancellor) on Sep 20, 2001 at 17:55 UTC | |
|
Re: AUTOLOAD detecting the type of method call.
by metcals1 (Acolyte) on Sep 20, 2001 at 18:24 UTC |