As I now understand your problem, we still do not have a solution. You use one (or more) existing module(s) which call sleep(). You wish to include the module sleep time(s) in your total. I devised the following test:
C:\Users\Bill\forums\monks>type Existing_module.pm use strict; use warnings; package Existing_Module; sub Do_Something { print "Doing something.\n"; sleep(3); } 1 C:\Users\Bill\forums\monks>type bliako.t use strict; use warnings; use lib '.'; use Test::More tests => 2; use Existing_Module; our $total_sleep_time; BEGIN { *actual_sleep = *CORE::sleep; *CORE::GLOBAL::sleep = sub (;$) { $total_sleep_time+=$_[0]; actual_sleep($_[0]) } } sleep(2); is($total_sleep_time, 2, 'Local'); Existing_Module::Do_Something(); # Sleeps for 3 sec. is($total_sleep_time, 2+3, 'Module'); C:\Users\Bill\forums\monks>perl bliako.t 1..2 ok 1 - Local Doing something. not ok 2 - Module # Failed test 'Module' # at bliako.t line 21. # got: '2' # expected: '5' # Looks like you failed 1 test of 2.

Several proposed solutions (including my previous post) can pass the first test. I have not found any that can pass the second. I have learned not to say that anything is impossible, but it does seem that this is intended to be.

Bill

In reply to Re^3: Copy a builtin sub to a different name and then override by BillKSmith
in thread Copy a builtin sub to a different name and then override by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.