Ver código fonte

[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.
tags/v0.9.8
Michael Brown 15 anos atrás
pai
commit
b4a87daeb9
1 arquivos alterados com 3 adições e 4 exclusões
  1. 3
    4
      src/util/padimg.pl

+ 3
- 4
src/util/padimg.pl Ver arquivo

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

Carregando…
Cancelar
Salvar