#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").
In reply to Re: Best practices for processing @ARGV ?
by ikegami
in thread Best practices for processing @ARGV ?
by gu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |