in reply to regexp look behind?

keep track of your last line's match. If you'll wrap your regex in parenthesis like so  if (/(cache|disk-)/i), you can assign the match to a variable, like so  $lastmatch = $1;, then each pass through your loop, you then can  print "\n" if ($lastmatch ne $1 and "disk-" eq lc $1);

Replies are listed 'Best First'.
Re^2: regexp look behind?
by dbs (Sexton) on Nov 30, 2010 at 19:24 UTC
    thanks but no cigar! I would like the output to be
    cache,23778,0.0,0,0.0,0,0.0,0.0,0.00 cache,205,0.0,0,0.0,0,0.0,0.0,0.00 "newline here" DISK-UTIL-PEAK-HIGH:,54.3,DISK-UTIL:,2.5 "newline here" PROC-Name,PID,PYS-IO-RATE,READs,READ-RATE,WRITEs cache,26094,0.9,1,0.9,0,0.0,0.0,0.00 cache,16046,0.0,0,0.0,0,0.0,0.0,0.00 cache,3848,0.0,0,0.0,0,0.0,0.0,0.00 cache,23778,0.0,0,0.0,0,0.0,0.0,0.00 cache,205,0.0,0,0.0,0,0.0,0.0,0.00 "newline here" DISK-UTIL-PEAK-HIGH:,54.3,DISK-UTIL:,3 ### last line ###

      No, thank you for finally clarifying just what you want the output to be!

        Yes, thanks for clarifying the output. that was something I could not parse from the discription given in the original problem.

        So take my original suggestion and instead of the if statement looking like I suggested make the print portion be  print "\n$_\n\n" if (same as code given).