Endless recursion would occur, if constant() is not being
found - for whatever reason... Normally, the routine is provided by the
XS code, but in case the wrong shared library is being loaded, or the symbol
isn't exported properly, or something like that, the call
to constant() would be routed to AUTOLOAD itself, leading to the
next level of recursion...
Quick proof of concept code:
#!/usr/bin/perl
package Image::Magick;
sub AUTOLOAD {
# This AUTOLOAD 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/.*:://;
print STDERR "$constname "; # DEBUG
my $val = constant($constname, @_ ? $_[0] : 0);
# the following code from the original sub is irrelevant (never re
+ached)
#if ($! != 0) {
# if ($! =~ /Invalid/) {
# $AutoLoader::AUTOLOAD = $AUTOLOAD;
# goto &AutoLoader::AUTOLOAD;
# }
# else {
# my($pack,$file,$line) = caller;
# die "Your vendor has not defined PerlMagick macro $pack\:
+\:$constname, used at $file line $line.\n";
# }
#}
#eval "sub $AUTOLOAD { $val }";
#goto &$AUTOLOAD;
}
package main;
Image::Magick::not_there(); # starts endless recursion
I'm not sure why lepetitalbert's respective print statement doesn't print
anything, but maybe it's just that STDOUT isn't connected to the
terminal here, or some such...
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|