in reply to Re: matching comments
in thread matching comments
my $start = "/*"; my $end = "*/"; my $inside = 0; my $oldpos = 0; $_ = "your text /* goes here */ and here"; while (/(\Q$start\E|\Q$end\E)/g) { if ($1 eq $start) { if (++$inside == 1) { $oldpos = pos($_) - length($start); } } else { if (--$inside == 0) { print substr($_, $oldpos, pos()-$oldpos); } } }
|
|---|