in reply to Re: THIS not THAT
in thread THIS not THAT

This is what I came up with. Comments? Criticisms?
foreach $rtr_diag(@diaglist) { next if ($rtr_diag =~ m/Clock|Switch|Power|Processor/); push @{$slots{$_}}, $rtr_diag; }

Replies are listed 'Best First'.
RE: RE: Re: THIS not THAT
by merlyn (Sage) on Oct 03, 2000 at 09:07 UTC
    This would almost certainly be faster:
    foreach (@diaglist) { next if /Clock/; next if /Switch/; next if /Power/; next if /Process +or/; push @something, $_; }
    The constant-text-only regex means that Boyer-Moore can kick in sooner, or so says the hints I read about regex a while back.

    -- Randal L. Schwartz, Perl hacker

      Survey says?

      Benchmark: timing 50000 iterations of Limo, merlyn...
            Limo: 17 wallclock secs (16.34 usr +  0.00 sys = 16.34 CPU) @ 3059.98/s (n
      =50000)
          merlyn:  2 wallclock secs ( 2.42 usr +  0.00 sys =  2.42 CPU) @ 20661.16/s (
      n=50000)

      Good instincts... =)

      --
      $you = new YOU;
      honk() if $you->love(perl)