Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: use vs. require in string eval?

by leriksen (Curate)
on Mar 12, 2004 at 03:25 UTC ( [id://336071]=note: print w/replies, xml ) Need Help??


in reply to use vs. require in string eval?

Isn't the whole point that use happens at compile time and require happens at run time. You can only benchmark run time behaviour...

So your eval "use $object_class"; is effectively trying to benchmark nothing except the eval overhead itself - which in this case is efectively nothing.

use is a declaration - require is a function - confusingly both are in the functions listed in chapter 3 of the camel book.

I would thus suspect that eval "use $object_class"; is actually wrong.

+++++++++++++++++
#!/usr/bin/perl
use warnings;use strict;use brain;

Replies are listed 'Best First'.
Re: Re: use vs. require in string eval?
by PodMaster (Abbot) on Mar 12, 2004 at 04:32 UTC
    It doesn't matter if "use" is a declaration, eval happens at runtime, and things that happen inside of string eval happen when eval happens.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Re: use vs. require in string eval?
by lachoy (Parson) on Mar 12, 2004 at 04:40 UTC

    I actually suspected this as well, but all the tests for Class::Factory still ran okay. If the 'eval "use..."' worked out to a no-op they would have failed all over the place.

    Chris
    M-x auto-bs-mode

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-26 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found