Quite true. Look at perlre for the comments
on the "?<!" operator (zero-width negative lookbehind assertion operator).
This will fix merlyn's code (where $file is the text you are parsing):
my $file = shift;
my $inside = 0;
my $oldpos = 0;
while ($file =~ /(?<!\\)(\Q$start\E|\Q$end\E)/g) {
if ($1 eq $start) {
if (++$inside == 1) {
$oldpos = pos($file) - length($start);
}
} else {
if (--$inside == 0) {
print substr($file, $oldpos, pos($file)-$oldpos);
}
}
}
the (?<!\\)\Q$start\E will match what is in $start but
not preceeded by a '\' character. |