develooper Front page | perl.perl5.porters | Postings from May 2008

Getopt::Long, + options, installperl, +v

From:
Nicholas Clark
Date:
May 18, 2008 11:40
Subject:
Getopt::Long, + options, installperl, +v
Message ID:
20080518184012.GJ6780@plum.flirble.org
So I was taking a look at the TODO

=head2 merge common code in installperl and installman

There are some common subroutines and a common C<BEGIN> block in F<installperl>
and F<installman>. These should probably be merged. It would also be good to
check for duplication in all the utility scripts supplied in the source
tarball. It might be good to move them all to a subdirectory, but this would
require careful checking to find all places that call them, and change those
correctly.

=cut

and I noticed that one of the differences between the two is that installperl
has variables $nonono and $verbose, whereas installman has $opts{notify} and
$opts{verbose}. This is because installman uses Getopt::Long, whereas
installperl has hand-rolled argument parsing.

So, I wondered whether installperl should be dragged into the century of
the fruitbat and converted to Getopt::Long.

However, I spot this potentially troubling bit of code:

    $versiononly = 1 if $ARGV[0] eq '-v';
    $versiononly = 0 if $ARGV[0] eq '+v';

which dates from 2001:

http://public.activestate.com/cgi-bin/perlbrowse/p/8747

Change 8747 by jhi@alpha on 2001/02/09 18:12:04

	Subject: versiononly and installperl
	From: abigail@foad.org
	Date: Wed, 7 Feb 2001 22:43:12 +0100
	Message-ID: <20010207214312.7045.qmail@foad.org>    
	
	Add +v flag to force a normal install of the perl binary
	and the utilities.
	
	Subject: [PATCH] installperl
	From: Nicholas Clark <nick@ccl4.org>
	Date: Fri, 9 Feb 2001 16:28:57 +0000
	Message-ID: <20010209162857.B10931@plum.flirble.org>
	
	Add -A flag which also hardlinks the binary with
	the full architecture name.


so I wondered how Getopt::Long copes with options starting with +
From skimming the man page and the code it seems that it can, if you set
getopt_compat. However, it seems that there is no way of it reporting back
whether one used a + or a - option.

So

1: is this correct?

2: if this is correct, should we find a new name for +v, and deprecate the
   old name? (and after the deprecation cycle completes, refactor to use
   Getopt::Long?)

(or is this makework, and life would be simpler if we replaced $nonono,
$verbose and friends with %opt, but kept the hand-rolled argument parsing
code?)

Nicholas Clark



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About