cmac has asked for the wisdom of the Perl Monks concerning the following question:
Also things seem to work the same whether there's a require AutoLoader or use AutoLoader near the start of my package.our $AUTOLOAD; sub AUTOLOAD { # this is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; croak "& not defined" if $constname eq 'constant'; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/ || $!{EINVAL}) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { croak "Your vendor has not defined MMA macro $constname"; } } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: autoloading tie routines
by ysth (Canon) on Feb 02, 2009 at 07:54 UTC | |
by cmac (Monk) on Feb 02, 2009 at 08:46 UTC | |
by cmac (Monk) on Feb 02, 2009 at 09:46 UTC | |
by ysth (Canon) on Feb 03, 2009 at 01:21 UTC | |
by ysth (Canon) on Feb 03, 2009 at 01:24 UTC |