Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Parsing logs and bookmarking last line parsed

by dasgar (Priest)
on Aug 19, 2010 at 19:08 UTC ( [id://856104]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Parsing logs and bookmarking last line parsed
in thread Parsing logs and bookmarking last line parsed

If you're ok with the idea of recording to a file the last time stamp that was used, it should be pretty simple to record which line you were last on too. You'll just need to modify your while loop a bit by adding a variable to keep track of the line numbers.

For a simple illustration, let's say that you read in from your new assistant file the last time stamp and the last line number read. Let's say that the last line read was stored in the variable $last_line_read. The code below illustrates the modification that you would need to do.

my $line_count = 0; while (my $line = <>){ $line_count++; next if ($line_count <= $last_line_read); # the rest of you code from the while remains the same }

I'm not saying that this is the "best" way to do it, but it should work.

Replies are listed 'Best First'.
Re^4: Parsing logs and bookmarking last line parsed
by JaeDre619 (Acolyte) on Aug 21, 2010 at 17:18 UTC
    Hi, thanks for your input on this. I was sort of playing around with this. I figured out how to grab the last count. I found using $. to store this number and I figured out how to dump this to a file.

    My question now is how can I use this as a place holder to start the regex the next time I run the script? I don't know if my logic works currently as I am grabbing data based on a given date, so I'm not sure if a count of record would help? or do you have another idea for a good key? thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found