Date sent:              Thu, 28 Aug 2008 17:25:16 +0200
From:                   sormariano <[EMAIL PROTECTED]>
To:                     beginners@perl.org
Subject:                Check for modules presence

> Hello to everybody,
> 
> I made a script that uses some modules.
> Obviously if one of the modules is not installed, the script doesn't start.
> I'd like to have the possibility to notify to the user which are the 
> modules he still requires and that should have to be installed..
> I think I could wrote an "install script" that checks the modules 
> presence and if all it's ok, it starts the main script.
> So here I have several questions:
> 1) is this a good way to proceed ?
> 2) how could I check the module presence ?
> 3) Can I start the main script with a 'system mainscript.pl'


Put something like this on top of the script:

BEGIN {
  push @INC, sub {print STDERR "Still looking for $_[1]\n";exit;};
}

You can of course not only inform the user, but also attempt to 
install the module for him or something like that.

See the "require" section in perldoc perlfunc, the "hooks".

HTH, Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to