Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Finding and extracting lines of text

by mikevanhoff (Acolyte)
on Jul 30, 2003 at 12:52 UTC ( [id://279163]=note: print w/replies, xml ) Need Help??


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

Anthony, Thanks for the code. It does almost what I need it to do. It prints the line I seek, but I need to skip the next 2 lines and print the 3rd line. It happens that if the data dump is successful, this line would then also be the last line in the log. Once I can extract the correct lines from a successful dump log, I will need to handle the case of a failed dump log which should come in an else clause of the if statement. does this make sense, or should I make a better explaination. Thanks in advance.
  • Comment on Re: Re: Finding and extracting lines of text

Replies are listed 'Best First'.
Re3: Finding and extracting lines of text
by swkronenfeld (Hermit) on Jul 30, 2003 at 16:58 UTC
    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.

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://279163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found