Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: (Ovid - try eval)Re: Only

by autark (Friar)
on Dec 11, 2000 at 22:48 UTC ( #46113=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://46113]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2020-11-30 05:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?