Re: how to check if some module is installed or not
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 10 Nov 2005 11:46:53 GMT
Serge A. Ribalchenko <I_feel_this_is_a_bad_idea@xxxxxxx> wrote in comp.lang.perl.misc:
> -=-=-=-=-=-
>
> Hi there,
>
> I want to check if some module, say, CGI, is installed in system, before I
> decide to use it or to do some workarounds. Should I check @INC or there
> is a more simple solution?
If you want to load the module if it is installed (as opposed to deciding
if it is installed without loading it), wrap a require statement in an
eval to catch the error (untested):
unless ( eval { require CGI; 1 } ) {
# not found, do something...
}
You can wrap a BEGIN {} around that if you need the action at compile
time, as in "use".
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- References:
- how to check if some module is installed or not
- From: Serge A. Ribalchenko
- how to check if some module is installed or not
- Prev by Date: Re: Use of \s versus space character
- Next by Date: pack /unpack issue
- Previous by thread: how to check if some module is installed or not
- Next by thread: Re: how to check if some module is installed or not
- Index(es):
Relevant Pages
|