You appear to have missed the significance of the following in my version:
HELP_MESSAGE() and exit unless $ARGV[1];
foreach (@ARGV) {
HELP_MESSAGE() and exit unless /^-?\d+$/
}
As I stated, I removed the error checking from the variable assignments et cetera. The reason I did so is for maintainability. If you didn't miss that, and find that my approach is deficient, please let me know how it fails to achieve roughly the same results in use.
edit: More explicitly, I've changed liverpole's
use File::Basename;
# [unrelated code]
my $iam = basename $0;
# [unrelated code]
# Command-line
(my $x = shift) or die $syntax;
(my $y = shift) or die $syntax;
# Validity checking
($x =~ /^-?\d+$/) or die "$iam: value $x not an integer\n";
($y =~ /^-?\d+$/) or die "$iam: value $y not an integer\n";
to . . .
HELP_MESSAGE() and exit unless $ARGV[1];
foreach (@ARGV) {
HELP_MESSAGE() and exit unless /^-?\d+$/
}
my $start = shift @ARGV;
my $end = shift @ARGV;
edit: johngg pointed out the "unless" bug above, where unless @ARGV should read unless defined @ARGV instead.
print substr("Just another Perl hacker", 0, -2); |
|
- apotheon
CopyWrite Chad Perrin |