OLD | NEW |
(Empty) | |
| 1 #! /usr/bin/env perl |
| 2 |
| 3 use warnings; |
| 4 use 5.005; |
| 5 use strict; |
| 6 |
| 7 my %option; |
| 8 while (<>) |
| 9 { |
| 10 if (/^\s* # Initial spaces. |
| 11 (?:(-\w),\s+)? # $1: Possible short option. |
| 12 (--[-\w]+) # $2: Long option. |
| 13 (\[?) # $3: '[' iff the argument is optional. |
| 14 (?:=([-\w]+))? # $4: Possible argument name. |
| 15 /x) |
| 16 { |
| 17 my ($short, $long, $opt, $arg) = ($1, $2, $3, $4); |
| 18 $short = defined $short ? '@option{' . $short . '}' : ''; |
| 19 if ($arg) |
| 20 { |
| 21 $arg =~ s/^=//; |
| 22 $arg = '@var{' . lc ($arg) . '}'; |
| 23 $arg = '[' . $arg . ']' |
| 24 if $opt eq '['; |
| 25 $option{"$long=$arg"} = $short ? "$short $arg" : ''; |
| 26 } |
| 27 else |
| 28 { |
| 29 $option{"$long"} = "$short"; |
| 30 } |
| 31 } |
| 32 } |
| 33 |
| 34 foreach my $long (sort keys %option) |
| 35 { |
| 36 printf "\@item %-40s \@tab %s\n", '@option{' . $long . '}', $option{$long}; |
| 37 } |
OLD | NEW |