in reply to Importing Time::HiRes::time at run-time (and failing)
When perl compiles your function, it checks if time has been redefined in the current package and if so, it emits opcodes to call a subroutine called "time", otherwise, it emits the time opcode (pp_time). As you are defining time after compilation, the time call is being compiled as the built-in and so the function from Time::HiRes never gets called.
You can work around it as follows:
sub new { require Time::HiRes; return bless { t => Time::HiRes::time() }, 'P' }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Importing Time::HiRes::time at run-time (and failing)
by grinder (Bishop) on Apr 20, 2006 at 15:10 UTC | |
by salva (Canon) on Apr 20, 2006 at 15:28 UTC |