SPUG: Can't print from within AUTOLOAD
Satish Gupta
globetrotcom at yahoo.com
Tue Jun 6 13:13:35 PDT 2006
Does the "print" statement inside the AUTOLOAD function print somewhere else? Even though the following AUTOLOAD function is being called, I am not seeing the output of "print" statement on stdout!
Thanks for your help.
-------------
sub AUTOLOAD
{
print "in AUTOLOAD $/";
no strict "refs";
my ($self, $newval) = @_;
# Was it a get_... method?
print "\$AUTOLOAD=$AUTOLOAD $/";
if ($AUTOLOAD =~ /.*::get(_\w+)/ && $self->_accessible($1,'read'))
{
my $attr_name = $1;
*{$AUTOLOAD} = sub { return $_[0]->{$attr_name} };
return $self->{$attr_name}
}
# Was it a set_... method?
if ($AUTOLOAD =~ /.*::set(_\w+)/ && $self->_accessible($1,'write'))
{
my $attr_name = $1;
*{$AUTOLOAD} = sub { $_[0]->{$attr_name} = $_[1] };
$self->{$1} = $newval;
return
}
# Must have been a mistake then...
croak "No such method: $AUTOLOAD";
}
--------------
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/spug-list/attachments/20060606/7cd0037b/attachment.html
More information about the spug-list
mailing list