Subject: | Incompatibility with Regexp::Common |
I'd like to use Regexp::Common to validate parameter values, but so far
haven't been succesful. I load the modules as such:
use Regexp::Common qw/number/;
use Getopt::Euclid qw( :minimal_keys );
As a silly example, if I write the spec as
delta.type: /$RE{num}{real}/
I get the result:
Getopt::Euclid: Unknown type (/$RE{num}{real}/) in specification:
--delta <delta> | -d <delta>
If I write it as
delta.type: string, delta =~ /$RE{num}{real}/
I get the result:
Getopt::Euclid: Invalid .type constraint: delta.type: string,
/$RE{num}{real}/
(Global symbol "%RE" requires explicit package name at (eval 7) line 1,
<$fh> line 1.
)
I tried runtime loading of Getopt::Euclid (in case for some reason
Regexp::Common loaded things on demand somehow, which it doesn't look
like it does):
use Regexp::Common qw( number );
print "it's real!\n" if "33.2" =~ /$RE{num}{real}/;
eval 'use Getopt::Euclid; 1;' or die $@;
with the following results:
% perl ~/tmp/goe
it's real!
Getopt::Euclid: Invalid .type constraint: delta.type: string, delta =~
/$RE{num}{real}/
(Global symbol "%RE" requires explicit package name at (eval 8) line 1,
<$fh> line 1.
)
BEGIN failed--compilation aborted at (eval 2) line 1.
Complete code follows:
#!/usr/bin/perl
use strict;
use warnings;
use Regexp::Common qw( number );
print "it's real!\n" if "33.2" =~ /$RE{num}{real}/;
eval 'use Getopt::Euclid; 1;' or die $@;
__END__
=head1 OPTIONS
=over
=item --delta <delta> | -d <delta>
The string used to prefix the output file name(s).
=for Euclid
delta.type: string, delta =~ /$RE{num}{real}/
delta.default: +2
=back