Show quoted text> Both the hash tests failed on my machine (OS X 10.5.7 with a source
> compiled 5.10.0). Attached is the verbose output of those tests.
I cannot replicate this on the same system and version of Perl. Can you
give me a perl -V so I can compare the Perl versions more closely.
More importantly, the error messages don't make sense. There's nothing
in the test's code that would undefine the value of $first_only.
That's the root cause here, because the corresponding match then fails
and the eq comparison in the test is to the result of the previous
successful match.
Can you rerun the following variation on hash.t so we can track down the
mysterious undefiner?
Thanks,
Damian
-----cut----------cut----------cut----------cut----------cut-----
use 5.010;
use warnings;
use Test::More 'no_plan';
my %hash = (
do => 'a deer',
re => 'a drop of golden sun',
dore => 'a portal',
me => 'a name I call myself',
fa => 'a long long way to run',
);
my $other = 1; # Needed to counteract bug in scoping (?)
my $listified = do {
use Regexp::Grammars;
qr{ <[WORD=%hash]>+ }xms;
};
my $first_only = do {
use Regexp::Grammars;
qr{ <WORD=%hash> }xms;
};
warn defined $first_only;
my $no_cap = do {
use Regexp::Grammars;
qr{ <%hash>+ }xms;
};
warn defined $first_only;
while (my $line = <DATA>) {
warn defined $first_only;
my ($input, $expected) = split /\s+/, $line;
warn defined $first_only;
if ($input =~ $listified) {
is_deeply $/{WORD}, eval($expected), "list: $input";
}
else { is 'FAIL', $expected, "list: $input"; }
warn defined $first_only;
if ($input =~ $first_only) {
is $/{WORD}, eval($expected)->[0], "scalar: $input";
}
else { is 'FAIL', $expected, "scalar: $input"; }
if ($input =~ $no_cap) { isnt 'FAIL', $expected, "no-cap: $input"; }
else { is 'FAIL', $expected, "no-cap: $input"; }
}
__DATA__
dorefameredo ['dore','fa','me','re','do']
dorefamell ['dore','fa','me']
zzzzz FAIL
zzzdoremezzz ['dore','me']