in reply to Getopt::Long Validation
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 = <FH>); } 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
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Getopt::Long Validation
by Ninthwave (Chaplain) on Oct 20, 2003 at 20:57 UTC | |
|
Re: Re: Getopt::Long Validation
by Ninthwave (Chaplain) on Oct 21, 2003 at 13:58 UTC | |
by jeffa (Bishop) on Oct 21, 2003 at 15:18 UTC | |
by Ninthwave (Chaplain) on Oct 21, 2003 at 20:58 UTC |