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

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

Nicholas Clark
May 18, 2008 11:40
Getopt::Long, + options, installperl, +v
Message ID:
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


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:

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

	Subject: versiononly and installperl
	Date: Wed, 7 Feb 2001 22:43:12 +0100
	Message-ID: <>    
	Add +v flag to force a normal install of the perl binary
	and the utilities.
	Subject: [PATCH] installperl
	From: Nicholas Clark <>
	Date: Fri, 9 Feb 2001 16:28:57 +0000
	Message-ID: <>
	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.


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

(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

Nicholas Clark Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About