Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://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.

Scott

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 regex_test.pl) 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 regex_test.pl) 1..2 not ok 1 - extraction string defined # Failed test 'extraction string defined' # at regex_test.pl 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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-23 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found