I discovered the problem:
print "Yes r\n" if "0" =~ /0/;
print "Yes s\n" if "0" =~ "0";
printed only "Yes s"
The problem is NOT in the RE engine, but in the string literal code in
P6C/Tree/String.pm
I replaced some "if ($stuff)" with "if (defined $stuff)" and now it
works. The problem was that a string "0" is false, but it's not the
same as "" (which would get used instead).
Proof:
print "0";print "\n";
prints an empty line.
I attach a small patch: it's quite possible that by adding 'defined'
in several places I broke something else. People familiar with the
code will undoubtedly correct my patch.
--
Dakkar - <Mobilis in mobile>
Index: String.pm
===================================================================
RCS file: /cvs/public/parrot/languages/perl6/P6C/Tree/String.pm,v
retrieving revision 1.2
diff -u -r1.2 String.pm
--- String.pm 6 Sep 2002 07:55:58 -0000 1.2
+++ String.pm 8 Oct 2002 09:28:54 -0000
@@ -60,7 +60,7 @@
my ($list) = shift;
my @flat;
foreach my $item (@$list) {
- if ($item) {
+ if (defined $item) {
if (ref $item eq 'ARRAY') {
push (@flat, interpolate_expand($item))
}
@@ -83,13 +83,13 @@
# something weird done to them.
if (ref $item eq 'P6C::variable') {
- push (@short, escape($string)) if $string;
+ push (@short, escape($string)) if defined $string;
push (@short, $item->tree);
$string='';
}
elsif (ref $item eq 'P6C::interpolated_value') {
- push (@short, escape($string)) if $string;
+ push (@short, escape($string)) if defined $string;
push (@short, $item->tree);
$string='';
@@ -97,7 +97,7 @@
else { $string.=$item }
}
- push (@short, escape($string)) if $string;
+ push (@short, escape($string)) if defined $string;
return \@short
}
@@ -119,7 +119,8 @@
}
else {
return new P6C::sv_literal type => $type,
- lval => ($list->[0] || '""')
+ #lval => ($list->[0] || '""')
+ lval => (defined $list->[0] ? $list->[0] : '""')
}
}