abbrev.pl + newgetopt.pl = NEAT! 
Author Message
 abbrev.pl + newgetopt.pl = NEAT!

        After using newgetopt.pl for awhile, I decided that I would
really like to have all the wonderful functionality that it provides
beyond getopt, but I would also like to use short option names too!
Therefore, I added some code to use the abbrev.pl package and now it
maps all unique abbreviations of the options into the correct option.

        It was really very simple, but if anyone is interested, here
are the diffs:

6,7c6,7
< # Last Modified By: Doug Gray
< # Last Modified On: Mon Nov 29 19:15:44 1993
---

Quote:
> # Last Modified By: Johan Vromans
> # Last Modified On: Tue Jun  2 11:24:03 1992

55,62d54
< # 29-Nov-1993              Doug Gray
< #    Use the "abbrev.pl" package to allow all possible mappings from
< #    unique abbreviations into the options.  E.g. if the call
< #    &NGetOpt( ('long', 'level=s', 'release=s') );
< #    is made,  then "-r", "-re", "-rel"... will all be recognized as
< #    the release option; "-lo" as the long option; "-le" as the level
< #    option; and "-l" will be invalid, as it is not a unique abbreviation.
<
89d80
<     require "abbrev.pl";
145,165d135
<     # Set up the Associative Array for abbreviations.
<     %AbbOpt = ();
<     &main'abbrev(*AbbOpt, keys %opctl);
<
<     # Only print the list of abbreviations if they REALLY need it.
<     if ($debug > 1) {

<    while ( ($k, $v) = each(%AbbOpt) ) {

<            $len = length($k) > $len ? length($k) : $len;
<    }
<
<    $arrow = "=> ";

<        ($v, $k) = split(/\|/);
<        print STDERR "$arrow\"$k\"", " "x($len - length($k)),
<                     " = \"$v\"\n";
<        $arrow = "   ";
<    }
<     }
<
192c162
<    unless  ( defined ( $postopt = $AbbOpt{$opt} ) ) {
---
Quote:
>    unless  ( defined ( $type = $opctl{$opt} ) ) {

197,199d166
<
<    # Redefine $opt to be the unabbreviated version and set $type
<    $type = $opctl{ $opt = $postopt };


Sat, 18 May 1996 10:49:37 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Changes to NGetOpt in newgetopt.pl

2. Source: newgetopt.pl version 1.14

3. Abbreviation support for newgetopt.pl

4. any additional docs for newgetopt.pl?

5. newgetopt.pl

6. Newgetopt.pl, version 1.13.

7. Official patch to newgetopt.pl 1.9

8. bug in newgetopt.pl

9. newgetopt.pl by Johan Vromans version 1.13

10. newgetopt.pl

11. newgetopt.pl dumps core

12. execute b.pl script from within a.pl script and b.pl vars remain

 

 
Powered by phpBB® Forum Software