D
Daniel Berger
Hi all,
Perl 5.8.3
Solaris 9
I'm trying to use the <> operator in Getopt::Long to call a sub when
an unknown option occurs. However, it doesn't seem to work. I read
the docs, found a few online examples, but nothing that would indicate
why this would fail. It's probably something obvious but I don't see
it.
Help appreciated.
Regards,
Dan
# getopttest.pl
use strict;
use Getopt::Long;
$Getopt::Long::debug = 9;
#Getopt::Long::config qw(permute); # tried both
$Getopt::Long:rder = $PERMUTE;
my($qt_dir, $CC);
# never gets called afaict
sub foo{
my $arg = shift;
print "WTF?-> $arg\n";
}
# Why isn't <> working?
GetOptions(
"--with-qt=s" => \$qt_dir,
"--with-gcc=s" => \$CC,
"<>" => \&foo
);
$CC ||= $ENV{CXX};
print "QT dir: $qt_dir\n";
print "CC: $CC\n";
# Output
ARGV: (--foo)
autoabbrev=1,bundling=0,getopt_compat=1,gnu_compat=0,order=1,
ignorecase=1,requested_version=0,passthrough=0,genprefix="(--|-|\+)".
=> link "with-qt" to SCALAR(0x12cd14)
=> link "with-gcc" to SCALAR(0x12ccf0)
=> $opctl{with-gcc} = ARRAY(0x12ccb4) ["s","with-gcc",O,$,"<undef>"]
$opctl{with-qt} = ARRAY(0x1ca584) ["s","with-qt",O,$,"<undef>"]
=> arg "--foo"
=> find "--foo"
=> split "--"+"foo"
=> 0 hits () with "foo" out of 2
Unknown option: foo
QT dir:
CC: g++ -Wall -m64 -mcpu=ultrasparc -fno-strict-aliasing
Perl 5.8.3
Solaris 9
I'm trying to use the <> operator in Getopt::Long to call a sub when
an unknown option occurs. However, it doesn't seem to work. I read
the docs, found a few online examples, but nothing that would indicate
why this would fail. It's probably something obvious but I don't see
it.
Help appreciated.
Regards,
Dan
# getopttest.pl
use strict;
use Getopt::Long;
$Getopt::Long::debug = 9;
#Getopt::Long::config qw(permute); # tried both
$Getopt::Long:rder = $PERMUTE;
my($qt_dir, $CC);
# never gets called afaict
sub foo{
my $arg = shift;
print "WTF?-> $arg\n";
}
# Why isn't <> working?
GetOptions(
"--with-qt=s" => \$qt_dir,
"--with-gcc=s" => \$CC,
"<>" => \&foo
);
$CC ||= $ENV{CXX};
print "QT dir: $qt_dir\n";
print "CC: $CC\n";
# Output
Getopt::Long 2.34 ($Revision: 2.68 $) called from package "main".perl getopttest.pl --foo
ARGV: (--foo)
autoabbrev=1,bundling=0,getopt_compat=1,gnu_compat=0,order=1,
ignorecase=1,requested_version=0,passthrough=0,genprefix="(--|-|\+)".
=> link "with-qt" to SCALAR(0x12cd14)
=> link "with-gcc" to SCALAR(0x12ccf0)
=> $opctl{with-gcc} = ARRAY(0x12ccb4) ["s","with-gcc",O,$,"<undef>"]
$opctl{with-qt} = ARRAY(0x1ca584) ["s","with-qt",O,$,"<undef>"]
=> arg "--foo"
=> find "--foo"
=> split "--"+"foo"
=> 0 hits () with "foo" out of 2
Unknown option: foo
QT dir:
CC: g++ -Wall -m64 -mcpu=ultrasparc -fno-strict-aliasing