[Chicago-talk] ->can and AUTOLOAD
Jay Strauss
me at heyjay.com
Thu Dec 4 10:47:00 CST 2003
Here is how I did it:
sub AUTOLOAD {
no strict "refs";
my ($self,$arg) = @_;
$AUTOLOAD =~ /.*::(\w+)/;
my %method;
@method{@TWSMethod} = ();
my $sub = $1;
return if $sub =~ /DESTROY/;
die "ERROR: This package does not implement the $sub message\n".
"\tthis is a problem" unless exists $method{$sub};
*{$AUTOLOAD} = sub {
print "In default $sub: You should override this method in your
code\n";
print "\t",join("\n\t",map{"$_=>".($arg->{$_} or "undef")} keys
%$arg),
"\n";
}
}
And then in my code I do:
$self->$subName(@arg);
----- Original Message -----
From: "Ed Summers" <ehs at pobox.com>
To: "Chicago.pm chatter" <chicago-talk at mail.pm.org>
Sent: Thursday, December 04, 2003 10:17 AM
Subject: Re: [Chicago-talk] ->can and AUTOLOAD
> On Thu, Dec 04, 2003 at 10:03:06AM -0600, Jay Strauss wrote:
> > Asking. But it doesn't matter, I'm just calling the method, and
checking
> > in my AUTOLOAD sub to see if this method is allowable
>
> can() is found in UNIVERSAL.pm. Let's see the code :)
>
> //Ed
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
>
More information about the Chicago-talk
mailing list