Dave
Dave

Reputation: 4328

Perl program to print POD when wrong arguments are passed in

How can I get a perl program to print the POD contents when an incorrect argument or number of arguments are passed in?

Upvotes: 1

Views: 212

Answers (3)

FishMonger
FishMonger

Reputation: 77

I'd use the Pod::Usage module

The Getopt::Long module has a good example on its usage.

Upvotes: 8

edem
edem

Reputation: 3272

If it about your program, I think you have to use:

sub usage {
  print<<help
  Usage $0: description of your script
help
}

if (($#ARGV+1) != $count_args) { usage; }

Upvotes: -1

Galimov Albert
Galimov Albert

Reputation: 7357

You can call exec("perldoc", $0); when arguments is wrong. So user will get man-like help.

Upvotes: -1

Related Questions