Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
"be consistent"
 
PerlMonks  

Re^2: use deprecated;

by adrianh (Chancellor)
on Nov 26, 2003 at 18:55 UTC ( [id://310423]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: use deprecated;
in thread use deprecated;

Sneaky. Like it.

You'd also need to check that the subroutine actually exists at INIT time, and wrap AUTOLOAD with something appropriate if it's defined.

As liz points out this won't work in mod_perl, eval and other places where the INIT phase has already occured.

I guess you could use a source filter to inline the wrapping code - but that would be really evil ;-)

Replies are listed 'Best First'.
Re^3: use deprecated;
by Aristotle (Chancellor) on Nov 27, 2003 at 20:18 UTC
    Actually, you don't even need to check whether the function exists. If you take a reference to a named but undefined function, it magically works once that function is defined. Perl is devious that way.
    #!/usr/bin/perl $_ = \&x; *x = sub { print "Oh my\n" }; $_->();
    This actually prints "Oh my".

    Makeshifts last the longest.

      Actually, you don't even need to check whether the function exists. If you take a reference to a named but undefined function, it magically works once that function is defined. Perl is devious that way.

      You're quite correct - I'm an idiot.

      In fact, I'm an idiot on two counts. My AUTOLOAD comment is equally bogus. Since everything is happening at INIT time the AUTOLOAD subroutine will already be defined.

      I restate my "sneaky" comment. Very nice :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://310423]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.