http://qs1969.pair.com?node_id=279261


in reply to Re: Re: Finding and extracting lines of text
in thread Finding and extracting lines of text

so just throw away the first two lines. Here's a quick fix on ajdelore's code

$success = 0; open(FILE,"dumptape.log") or die ("Could not open file"); while(<FILE>) { if (/Dump phase number 3/) { print; <FILE> for (1..2); print <FILE>; $success = 1; last; } } if(!$success) { print "Failed dump log\n"; #do other failed dump log stuff here } close FILE;

It seems like you have an understanding of some areas of perl, but are lacking some of the basics. You should look for an online tutorial (or better, one of the O'Reilly books), to pick up on a few of the little things you're missing.

Replies are listed 'Best First'.
Re: Re3: Finding and extracting lines of text
by mikevanhoff (Acolyte) on Jul 30, 2003 at 21:09 UTC
    I really appreciate all of the help. I have been searching the O'Reilly books for some of the basics I must have missed, but no where can I find a reference to my problem. The code presented here has been a great help in finding the first line I am searching. However, I am not sure that I am making my clear. I do need to find the line, but it is the NEXT LINE I need to print. THEN I need to SKIP 2 Lines and print the third. It is the skipping lines part that I am having problems doing. It seems logical that calling the <FILE>; on a line would read in the next line, but it does not appear to work. If this is still not clear, please let me know. I do not want to waste anyone's time. I can be email privately at mikev@beverlycorp.com Thanks