Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re^3: Getopt::Euclid victim of 5.10 upgrade by scott\b
in thread Getopt::Euclid victim of 5.10 upgrade by scott\b

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [bounim]: yo

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (2)
    As of 2018-01-21 22:50 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (230 votes). Check out past polls.