#!/usr/bin/env perl use strict; use warnings; my $total_sleep_time = 0; BEGIN { *CORE::GLOBAL::sleep = sub(;@) { $total_sleep_time+=$_[0]; CORE::sleep($_[0]) } } # use this module and the other # ... print "\$]=$] \$^V=$^V\n"; sleep(2); print "total sleep is $total_sleep_time\n";