in reply to Re^2: 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
That's a good start.
On quick inspection:
You could use @array = open (TEXT_FILE, "file1.txt"); to read your file into an array and then test each element of the array rather than using while. That might make it easier to work out the logic needed to satisfy the "ten lines" requirement.
AND, read perldoc -f open for the three argument form of open (and always test the open: or die "Can't open file1.txt: $!\n";).
Life will also be easier if you use clear and consistent indenting (which of the various recommendations you follow is a matter of taste). Hint for posting here: "Preview, perview, preview! A string of spaces renders differently than a tab.
You'll get better answers if you tell in detail what "nowhere" means, in terms of output, error & warnings messages and a better set of sample data (see my previous questions: you've answered some of them, but left some crucial elements of your spec to our crystal balls - most of which are still broken).
|
|---|