Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^3: Getopt::Euclid victim of 5.10 upgrade

by scott\b (Novice)
on Feb 17, 2009 at 03:58 UTC ( #744285=note: print w/replies, xml ) Need Help??

in reply to Re^2: Getopt::Euclid victim of 5.10 upgrade
in thread Getopt::Euclid victim of 5.10 upgrade

Thank you all for your help and insight. Unfortunately, I see little recourse but to abandon my use of Getopt::Euclid. I'm not going to rewrite existing scripts for now, but I won't use Getopt::Euclid for a new research project I am starting.

The straw that broke the camel's back (so to speak) is the inconsistent failures. It works for me on OS X with perl 5.10 but fails for telemachus. Further, it works with one build of perl 5.10.0 on linux and fails for a different build of 5.10.0 on the same system.

I lack time and motivation to trace the failure all the way back to perl build configuration settings, especially since it appears that Damian Conway has abandoned Getopt::Euclid.

Once again, thank you for your help.


P.S. I rewrote my sample code to be a proper Test::More test script. Furthermore, I also reverted to the original regular expression, in case my simplification introduced its own errors.

#!perl use strict; use warnings; use Config; use Test::More tests => 2; =pod This code provides a test case for a very complex regular expression constructed by Getopt::Euclid v0.2.0. Under some releases of perl (i.e. cygwin 5.10.0 and OS X 5.10.0) the regular expression fails. However, on other systems running the same OS & perl combination, the same code works. A simplified regular expression used in an earlier problem report was discarded. While it apparently duplicated the problem, there was no assurance the simplification did not introduce its own problem. The original Getopt::Euclid generated expression, used below, is trying to do the following: * There is logic there (the exists clause) to prevent matching the string more than once; the --now option is only allowed once according to my Getopt::Euclid directive. * It will match the literal string '--now' followed by an integer (e.g. 0, 10, -42, +1999). If it can, that information is stored in a convoluted hash + array using both the option specification (i.e. '--now <seconds>') and the option placeholder (i.e. 'seconds'). * It stores any errors in the @errors array. * All that said, there is still some fine magic I have not taken the time to grok. =cut my %ARGV; my $string = q{It is --now 1234}; my @errors; # If you download the code replace the two character '^N' with a # proper control-N. $string =~ s{ (?: (??{exists$ARGV{q{--now <seconds>}}?'(?!)':''}) --now [\s\0\1]* (?:([+-]?\d+)(?{($ARGV{q{--now <seconds>}}||=[{}])->[-1]{q{seconds +}} = $^N})) (?:(?<!\w)|(?!\w)) (?{$ARGV{q{--now <seconds>}} ||= [{}] }) |(?> (.+)) (?{ push @errors, $^N }) (?!) ) }{thyme}xsm; ok( defined $ARGV{q{--now <seconds>}}->[-1]{seconds}, 'extraction string defined' ); is( $string, 'It is thyme', 'string replacement worked' ); diag("Perl version = $Config{version} on $Config{osname}:\n"); diag( '$ARGV{q{--now <seconds>}}->[-1]{seconds} = ' . ( defined $ARGV{q{--now <seconds>}}->[-1]{seconds} ? "'$ARGV{q{--now <seconds>}}->[-1]{seconds}'" : 'undef' ) . "\n" ); use Data::Dumper; diag( Data::Dumper->Dump( [ \%ARGV ] ) ); exit 0;
That code, when run twice on my system, reports:
: 2009-02-16 21:47:21 (C:/Perl510/bin/perl 1..2 ok 1 - extraction string defined ok 2 - string replacement worked # Perl version = 5.10.0 on MSWin32: # $ARGV{q{--now <seconds>}}->[-1]{seconds} = '1234' # $VAR1 = { # '--now <seconds>' => [ # { # 'seconds' => '1234' # } # ] # };

: 2009-02-16 21:47:21 (perl 1..2 not ok 1 - extraction string defined # Failed test 'extraction string defined' # at line 56. ok 2 - string replacement worked # Perl version = 5.10.0 on cygwin: # $ARGV{q{--now <seconds>}}->[-1]{seconds} = undef # $VAR1 = { # '--now <seconds>' => [ # { # 'seconds' => undef # } # ] # }; # Looks like you failed 1 test of 2.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://744285]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-09-24 07:45 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (273 votes). Check out past polls.