in reply to Re: Searching for a string in a text and printing the next few lines
in thread Searching for a string in a text and printing the next few lines
#! /usr/local/bin/perl open (TEXT_FILE, "file1.txt"); while ($line = <TEXT_FILE>) { if ($line =~ m/ERROR/) { $c = 0; while ($c <= 10) { $nextline = <TEXT_FILE> ; printf ("$nextline"); $c = $c + 1; } } } close (TEXT_FILE);
and like you said vroom, if the search string is in multiple locations, I want to print all such instances, not just once..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Searching for a string in a text and printing the next few lines
by ww (Archbishop) on Nov 13, 2009 at 12:20 UTC |