[Israel.pm] Cool usage hack which I saw in another mailing list

Gabor Szabo szabgab at gmail.com
Fri Mar 4 07:36:50 PST 2005


On Fri, 04 Mar 2005 17:02:50 +0200, Omer Zak <omerz at actcom.co.il> wrote:
> There is a backup script at
> http://www.sanitarium.net/unix_stuff/backups/diff_backup.pl.txt which is
> too cool for words.

> The preceding is a really great idea. Why didn't everyone think of that?
> Much cleaner than an ugly usage() routine.

I would not use this code as an example of good coding standards. 
Only to show how can you take a shell-like perl script and create a
real perl script
from it.


And to the specific point of disaplying usage message.
I normally call usage() from several places not only when -h is given.
There might be a case of bad parameters provided or other reason to call
it so it is better to put it in a function. 

# comments are usually used for developer comments while 

=pod  is used for documentation.

Therefore the usage information should be part of the =pod and not
part of the comment.

...and then you could go with Pod::Usage that can extract part of the pod.

Gabor



More information about the Perl mailing list