while ($this->{template} =~ /$re/) { # Uses substr and @-/@+ instead of $` and $'. Also is sure to capture those values before executing other potentially regex-using code. my ( $prior, $start, $close, $after ) = = ( substr( $this->{template}, 0, $-[0] ), $1, $2, substr( $this->{template}, $+[0] ) ); my $params = $this->mask_block_params( $start, $close ); my $html = &$callback($key, $params); $this->{template} = $prior . $html . $after; }