Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by morgon (Priest)
on Jun 01, 2018 at 22:33 UTC ( [id://1215677]=note: print w/replies, xml ) Need Help??


in reply to Re: 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 node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Copy a builtin sub to a different name and then override
by Haarg (Priest) on Jun 03, 2018 at 10:27 UTC

    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.

Re^3: Copy a builtin sub to a different name and then override
by shmem (Chancellor) on Jun 03, 2018 at 14:57 UTC
    You can't be bother to even try trivial things yourself, can you?

    Did you?

    qwurx [shmem] ~> perl -lE 'say UNIVERSAL::can(bless(\$x, __PACKAGE__), + "CORE::GLOBAL::sleep")' qwurx [shmem] ~> perl -lE 'say UNIVERSAL::can(bless(\$x, __PACKAGE__), + "CORE::sleep")' CODE(0x1fafba8)

    See CORE.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^3: Copy a builtin sub to a different name and then override
by LanX (Saint) on Jun 01, 2018 at 22:40 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-29 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found