Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by LanX (Saint)
on Jun 02, 2018 at 00:52 UTC ( [id://1215708]=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 works for me under 5.016003 even without the correct prototype:

use strict; use warnings; warn "Version $]"; warn "Prototype", prototype "CORE::sleep"; my $sleepcounter; BEGIN { *CORE::GLOBAL::sleep = sub { warn "start wrapper"; $sleepcounter += $_[0]; CORE::sleep(@_); warn "stop wrapper"; }; } sleep 3; warn "total sleep( $sleepcounter )"
C:/Perl_64/bin\perl.exe d:/Users/lanx/pm/core_sleep.pl Version 5.016003 at d:/Users/lanx/pm/core_sleep.pl line 4. Prototype;$ at d:/Users/lanx/pm/core_sleep.pl line 5. start wrapper at d:/Users/lanx/pm/core_sleep.pl line 13. stop wrapper at d:/Users/lanx/pm/core_sleep.pl line 16. total sleep( 3 ) at d:/Users/lanx/pm/core_sleep.pl line 26.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-03-29 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found