use strict; use warnings; use Data::Dumper; use Config; use re 'eval'; my %ARGV; my $string = q{It is --now 12:34}; # Mimic Getopt::Euclid's generated regex to process a --now command line # option. $string =~ s{(??{exists $ARGV{WHEN} }) --now\s+(\d+:\d+)(?{$ARGV{WHEN} = $^N}) }{thyme}xsm; print "Perl $Config{version} on $Config{osname}:\n", Data::Dumper->Dump( [ \%ARGV, $string ], [qw(ARGV string)] ); exit 0; #### : 2009-02-10 19:56:05 (C:/Perl510/bin/perl regex_test.pl) Perl 5.10.0 on MSWin32: $ARGV = { 'WHEN' => '12:34' }; $string = 'It is thyme'; : 2009-02-10 19:56:05 (perl regex_test.pl) Perl 5.10.0 on cygwin: $ARGV = { 'WHEN' => undef }; $string = 'It is thyme';