in reply to Re: matching comments
in thread matching comments
the (?<!\\)\Q$start\E will match what is in $start but not preceeded by a '\' character.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); } } }
|
|---|