Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Interesting behavior in eval block

by ikegami (Patriarch)
on Jun 19, 2008 at 18:52 UTC ( [id://692997]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Interesting behavior in eval block
in thread Interesting behavior in eval block

Your "trick" doesn't work. You're just duplicating the work the implicit import in use already does. Like I said in my original post, it's *when* it happens that's important.

You have the right idea, but it needs to be done at compile-time. Fortunately, it's very simple since Perl already provides a means of declaring a function that's to be defined at a later time.

sub gettimeofday(); # Eventually. eval "use Time::HiRes qw( gettimeofday ); 1" or die "Unable to load Time::HiRes: $@\n"; print(gettimeofday);

The parens in "sub gettimeofday();" are only there because Time::HiRes declares the function using that prototype.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-16 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found