in reply to Print n lines after a matched line

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re^2: Print n lines after a matched line
by hippo (Archbishop) on Jun 14, 2018 at 14:55 UTC
    $ cat sd.pl my $counter = -1; # (so it's never zero until decrement does it) while (<IN>) { if /SCHEDULE/ { # (use right regex here) $counter = 2; } else if ($counter-- == 0) { // third line } } $ perl -cw sd.pl syntax error at sd.pl line 3, near "if /SCHEDULE/" syntax error at sd.pl line 6, near "else" sd.pl had compilation errors. $
Re^2: Print n lines after a matched line
by AnomalousMonk (Archbishop) on Jun 14, 2018 at 19:31 UTC

    I've written that after a long period of simply ignoring sundialsvc4's posts, I felt obliged to upvote a couple that actually seemed helpful. The flip side is that I'm now obliged to pay attention to and downvote the crappy ones, e.g., this. Life used to be so simple.


    Give a man a fish:  <%-{-{-{-<

A reply falls below the community's threshold of quality. You may see it by logging in.