in reply to THIS not THAT

Heh, jcwren demonstrates the first virtue of a Perl programmer. Here's something closer to what you intend:

print if /^SLOT/ && !(/Switch|Power|Clock|Processor/);

In one regex (ugly and not optimized and with more question marks than is healthy:

print if /^SLOT .*?: (?!(?:Clock|Switch|.*?Power|.*?Processor))/;

I'd go with the first.

Replies are listed 'Best First'.
RE: Re: THIS not THAT
by Limo (Scribe) on Oct 03, 2000 at 08:33 UTC
    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; }
      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)