Re: how to check if some module is installed or not



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.
.



Relevant Pages

  • Re: DVD questions
    ... The idea was that, eventually, the missing CGI side ... So the live footage is being shown the way it was intended to be shown ... So you never lost ... THE TOP AND BOTTOM to create a 16:9 version! ...
    (rec.arts.sf.tv.babylon5)
  • Re: Default cell alignment
    ... The to should be made the system install default rather than bottom. ... There is nothing harder to read then a wrap text print out aligned to the ... > Open a new workbook. ... > Excel will add the .XLT to save as BOOK.XLT. ...
    (microsoft.public.excel.misc)
  • Re: Freezing Lines
    ... When Can Grow is turned on, text will automatically wrap when it gets ... the line is below the bottom of the TextBox then the line will be pushed ... If you make the TextBox tall enough (pull the bottom downward) so that its ... Another possible alternative is to use the Print method of the report in ...
    (microsoft.public.access.reports)
  • Text wrap problem
    ... The text box is configured to "Square" text wrapping. ... wrap on Both Sides. ... The Distance From Text is set to .1 on Top and Bottom and ... The problem is that when the text around the text box reaches the bottom of ...
    (microsoft.public.word.drawing.graphics)
  • Re: Why my MATLAB software always shuts down by itself?
    ... Variables" button at the bottom. ... Hit "OK" a couple of times to wrap up. ... You are such a nice guy, you just put a very bright smile onto my ...
    (comp.soft-sys.matlab)