samtregar has asked for the wisdom of the Perl Monks concerning the following question:
Here's a bit of code that shows a simplified version of what I'm doing. CAUTION: this code loops infinitely printing "LOCK_EX called" - it might lock up your machine if you're not quick with Ctrl-C.
#!/usr/bin/perl -w use Fcntl qw(LOCK_EX); # instrument LOCK_EX my $lock_ex_coderef = \&Fcntl::LOCK_EX; *Fcntl::LOCK_EX = sub { print "LOCK_EX called\n"; return &$lock_ex_coderef; }; # call LOCK_EX $_ = LOCK_EX;
Now, what I'd expected was that this code would print "LOCK_EX called" just once and then call Fcntl::AUTOLOAD as usual. Can anyone think of a way to get that behavior? Or perhaps I just need to understand why this method isn't working. Can anyone explain why a calling code-ref to a "fake" sub causes this recursion?
Alternately, can anyone propose a way to detect "fake" subroutines so I could skip them for now? B:: solutions are acceptable.
Thanks!
-sam
|
---|