use strict; use warnings; use Pod::Usage; use Getopt::Long; our($file,$range,$help); GetOptions( 'file|f=s' => \$file, 'ip|i=s' => \$range, 'help|h' => \$help, ); pod2usage(-verbose=>2) if $help; unless ($file or $range) { $file = shift or pod2usage(-verbose=>1); } if ($file) { open FH, '<', $file or die "can't read $file\n"; chomp($range = ); } print "$range\n"; __END__ =head1 NAME foo.pl - does something with IP range =head1 SYNOPSIS foo.pl [filename] [-file filename] [-ip IPrange] Options: -file -f file to read -ip -i IP range -help -h help message =head1 EXAMPLES Read from file: foo.pl ip.txt foo.pl -f ip.txt foo.pl -file ip.txt Read from STDIN: foo.pl -i 127.0.0.1 foo.pl -ip 127.0.0.1