Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: The 'eval "require $module; 1"' idiom

by tobyink (Abbot)
on Apr 20, 2014 at 02:20 UTC ( #1082929=note: print w/ replies, xml ) Need Help??


in reply to Re: The 'eval "require $module; 1"' idiom
in thread The 'eval "require $module; 1"' idiom

Even in that case, I still wouldn't add ";1" to the evaluated string. In your example, use warnings would be complaining about concatenating an undefined value. Instead I'd probably go with

my $MODULE_WAS_LOADED = !! eval "require 'bar.pl'";

Or perhaps even:

my $MODULE_WAS_LOADED = 0+!! eval "require 'bar.pl'";

(which might look nicer in the debugging output).

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name


Comment on Re^2: The 'eval "require $module; 1"' idiom
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (18)
As of 2015-07-07 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (92 votes), past polls