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