Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: eval string possibilities

by Arunbear (Prior)
on Nov 22, 2004 at 11:49 UTC ( [id://409557]=note: print w/replies, xml ) Need Help??


in reply to eval string possibilities

eval string is also useful for loading modules dynamically e.g.
... my $q = CGI->new; my %modules = ( simple => 'Filter::Simple', hard => 'Filter::Util::Call' ); my $filter = $q->param("filter"); if(exists $modules{$filter}) { eval "require $modules{$filter}"; } ...
Without eval, you would have to convert the module name to a file path before passing it to require.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found