in reply to Getopt::Long Validation
(update: I do not mean to suggest that I'd never use of the Getopt modules -- I do use them often. It's just that for a simple case like this, option flags seem unnecessary: you have to provide one type of arg or the other, and you can't provide both -- these are not really "options", and you don't need a command-line flag to tell them apart.)use strict; my $Usage = "$0 lower.ip.addr-upper.ip.addr\n or\n$0 text.file\n"; die $Usage unless @ARGV == 1; my ($iplower, $ipupper); if ( -f $ARGV[0] ) { # treat the arg as a file } elsif ( $ARGV[0] =~ /^((?:\d{1,3}\.){3}\d{1,3})-(\d{1,3}(?:\.\d{1,3}){ +3})$/ ) { ($iplower,$ipupper) = ($1,$2); } else { die "Invalid command-line arg: $ARGV[0]\n\n$Usage"; } ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Getopt::Long Validation
by Ninthwave (Chaplain) on Oct 21, 2003 at 08:09 UTC |