in reply to Extracting HTML between comments

Looks like a good place for the flip-flop .. operator. So your code would look like this (untested).
while (my $token = $stream->get_token) { if (($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceBeginEditable name="article" -->') .. ($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceEnd -->')) +{ print $token->[1]; } }
Should work (although it might have off-by-one problems, and the style might be confusing). Alternately, you could use a separate variable to keep track of your state.
my $parsing=undef; while (my $token = $stream->get_token) { if ($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceBeginEditable name="article" -->'){ $parsing=1; } elsif ($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceEnd -->') { $parsing=undef; } elsif ($parsing) { print $token->[1]; } }