in reply to Best practices for processing @ARGV ?
#1 is buggy. A file name "0" will incorrectly die. The (not so pretty) solution:
defined(my $infile = shift) || die usage(); defined(my $outfile = shift) || die usage();
I find #2's unless (@ARGV == 2) harder to read than if (@ARGV != 2).
I'd print usage to STDERR, so I prefer die("message"), warn("message") and print STDERR ("message") over #1 and #2's print("message").
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best practices for processing @ARGV ?
by Hue-Bond (Priest) on Dec 13, 2005 at 01:39 UTC |