Interesting... Fcntl::AUTOLOAD never even gets called, and for some reason whatever's in the saved coderef just calls us again. My wild guess is that Perl puts some sort of magic reference to the autoloading code in that symbol table entry when it gets exported. When this code gets called, it looks and sees that the sub has been defined in the meantime (by you), and happily calls that, rather than looking for an autoload.
In any case, temporarily putting the old glob back in place fixes it, and AUTOLOAD is only called the first time, as things should be.
#!/usr/bin/perl -w
use Fcntl qw(LOCK_EX);
# instrument LOCK_EX
my $lock_ex_coderef = \&Fcntl::LOCK_EX;
my $newglob = *Fcntl::LOCK_EX = sub {
print "LOCK_EX called\n";
no warnings 'redefine';
*Fcntl::LOCK_EX = $lock_ex_coderef;
if (wantarray) {
my @ret = &$lock_ex_coderef;
*Fcntl::LOCK_EX = $newglob;
@ret;
} else {
my $ret = &$lock_ex_coderef;
*Fcntl::LOCK_EX = $newglob;
$ret;
}
};
# call LOCK_EX
print $_ = LOCK_EX;
print "\n";
/s
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.