[Za-pm] Script

Nick Cleaton nick at cleaton.net
Wed Jun 4 08:21:45 CDT 2003


On Wed, Jun 04, 2003 at 02:16:08PM +0200, Spike wrote:
> I see your use of perldoc entries - nice.
> Is there a simple way to force perldoc to launch if the user enters 
> ./myscriptwithdoc --help?
> 
> something like:
> 
> if ($ARGV[0] =~ /help/i)
> {
> system("perldoc $0");
> }

Interesting idea, I've never thought of doing that.

Something a bit stricter than /help/ might be a good idea, otherwise
someone could get in a mess trying to use it on a log file with 'help'
in its name.

Using exec() instead of system() will prevent the script from
continuing after running perldoc, and giving an error message when it
can't open a file called --help.

So maybe:

if ( $ARGV[0] eq '--help' ) {
    exec('perldoc', $0);
}

--
Nick



More information about the Za-pm mailing list