david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[build] Simplify use of Getopt::Long in padimg.pl

Sometimes it's just so much fun doing things the complicated way that
you forget to check the man page for the existence of a simpler
syntax.
This commit is contained in:
Michael Brown 2009-04-16 06:13:09 +01:00
parent 7aee624881
commit b4a87daeb9
1 changed files with 3 additions and 4 deletions

View File

@ -9,16 +9,15 @@ my $verbosity = 0;
my $blksize = 512;
my $byte = 0;
my $opts = {
my %opts = (
'verbose|v+' => sub { $verbosity++; },
'quiet|q+' => sub { $verbosity--; },
'blksize|s=o' => sub { $blksize = $_[1]; },
'byte|b=o' => sub { $byte = $_[1]; },
};
);
Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
GetOptions ( { map { /^(\w+)/; $1 => $opts->{$_} } keys %$opts }, keys %$opts )
or die "Could not parse command-line options\n";
GetOptions ( %opts ) or die "Could not parse command-line options\n";
while ( my $filename = shift ) {
die "$filename is not a file\n" unless -f $filename;