Subject: | Perl::Tidy may break if Getopt::Long::Configure is called before it |
I have a script that uses Pod::POM::View::HTML::Filter, which in turn uses Perl::Tidy to color blocks of Perl code between =begin filter perl / =end filter. The scripts uses Getopt::Long to parse its options list.
I found out that the Getopt::Long::Configure("bundling") line in my script provoked the following error in perltidy() (which I called with the options
line "-html -pre -nopod2html") :
Unknown option: n
Unknown option: o
Unknown option: p
Unknown option: o
Unknown option: d
Unknown option: 2
Unknown option: h
Unknown option: t
Unknown option: m
Unknown option: l
Attached you'll find a patch that corrects this, by setting Getopt::Long options back to default, before putting them back to whatever they were.
--- /usr/local/share/perl/5.8.3/Perl/Tidy.pm 2003-10-22 06:12:43.000000000 +0200
+++ Tidy.pm 2004-10-12 08:37:16.000000000 +0200
@@ -1279,9 +1279,16 @@
for $i (@defaults) { push @ARGV, "--" . $i }
+ # back to Getopt::Long defaults
+ my $glc = Getopt::Long::Configure();
+ Getopt::Long::ConfigDefaults();
+
if ( !GetOptions( \%Opts, @option_string ) ) {
die "Programming Bug: error in setting default options";
}
+
+ # put the previous Getopt::Long configuration back
+ Getopt::Long::Configure( $glc );
}
#---------------------------------------------------------------