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"; } ...