in reply to (Ovid - coming in late) Re: Substitute Question
in thread Substitute Question

You can replace:
if ( /$start_tag/ .. /$end_tag/ ) { if ( /$start_tag/ or /$end_tag/ ) {
with
if ( my $where = /$start_tag/ .. /$end_tag/ ) { if ( $where == 1 or $where =~ /E/ ) {
for more reliable (and faster!) operation.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
(Ovid) (3): Substitute Question
by Ovid (Cardinal) on May 30, 2001 at 02:40 UTC

    Hey, that's sweet! If you want to get rid of another regex and make it even faster:

    if ( $where == 1 or substr($where, -2) eq 'E0' ) {

    Though I am wondering one thing: why is 'E0' appended to the return value of the final sequence number? Is it just an easy test for the end or is there something significant here that I'm not aware of? (i.e., why not just append an 'x' or 'mssux' or something like that?).

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.