Hello All,
I have been working on some misc. junction tests for Pugs and I ran into an
item which I am not sure of. It has to do with a junction of variables which
is then assigned to variable itself, and how "bound" the variables inside the
junction are. This is best illustrated with code, so here is the test with
comments to explain:
my $a = 'a';
my $b = '';
my $c = '';
my $any_of_them = $b | $c | $a;
# this test passes
ok('a' eq $any_of_them, '($b | $c | $a) matches at least one "a"');
$b = 'b';
$c = 'c';
# this test passes ...
ok('a' eq $any_of_them, '($b | $c | $a) matches at least one "a"');
# but these two tests don't
ok('b' eq $any_of_them, '($a | $b | $c) matches at least one "b"');
ok('c' eq $any_of_them, '($c | $a | $b) matches at least one "c"');
Those last two tests do pass if I re-make the $any_of_them junction after
assigning $b and $c. This is actually best illustrated again with this code.
my $a = 'a';
my $b = '';
my $c = '';
my $any_of_them = $b | $c | $a;
say $any_of_them;
$b = 'b';
$c = 'c';
say $any_of_them;
my $any_of_them = $b | $c | $a;
say $any_of_them;
Which will print the following:
any(a)
any(a)
any(a,b,c)
So my question is; Is this correct? Or should $a, $b and $c be more tightly
bound within the $any_of_them junction?
Thanks in advance,
- Stevan