Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Copy a builtin sub to a different name and then override

by Haarg (Priest)
on Jun 03, 2018 at 10:27 UTC ( [id://1215774]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Copy a builtin sub to a different name and then override
in thread Copy a builtin sub to a different name and then override

This isn't checking if CORE::GLOBAL::sleep exists, it's forcing it to exist. It's another form of autovivification. Taking a reference to a nonexistent sub like this will create a stub in its place (like sub CORE::GLOBAL::sleep;). A stub of course isn't callable.

The correct way to check for the existence of a sub is using either exists &Some::sub or defined &Some::sub. exists will return true for subs that exist, even if they are stubs. defined will return true only for not-stub subs.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1215774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-18 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found