http://qs321.pair.com?node_id=46113


in reply to (Ovid - try eval)Re: Only
in thread Only

But the function time() from Time::HiRes will not be imported. To make this binding between &main::time and &Time::HiRes::time we have to this at compile time:
BEGIN { eval { require Time::HiRes; import Time::HiRes qw(time) }; if($@) { warn "Unable to import Time::HiRes\n" }; }
Without the BEGIN, the binding of time to the correct function would not happen:
eval { require Time::HiRes; import Time::HiRes qw(time) }; print time()
Would produce f.exs: 976556706. While
BEGIN { eval { require Time::HiRes; import Time::HiRes qw(time) }; } print time()
Would produce the correct time using the Time::HiRes::time function: 976556789.394509.

Autark.