Hi,
Which version of perl do you have?
See CORE and ex::override
#!/usr/bin/perl --
use strict;
use warnings;
use diagnostics;
BEGIN {
my $sleepcounter = 0;
*CORE::GLOBAL::hex = sub {
print qq{hex(@_)\n};
# goto &CORE::hex; ## FAIL
CORE::hex(@_);
};
*CORE::GLOBAL::sleep = sub(;@) {
print qq{sleep(@_)\n};
$sleepcounter += $_[0];
CORE::sleep(@_);
};
END { print "total sleep( $sleepcounter )\n"; }
}
print "\$]=$] \$^V=$^V\n";
sleep 1; print hex("0x50"),"\n";
sleep 2; print hex("0x50"),"\n";
__END__
$ perl core-global-sleep-override.pl
$]=5.016001 $^V=v5.16.1
hex(0x50)
1
hex(0x50)
1
total sleep( 0 )
$ perl core-global-sleep-override.pl
$]=5.020003 $^V=v5.20.3
sleep(1)
hex(0x50)
1
sleep(2)
hex(0x50)
1
total sleep( 3 )
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|