Re: Newbie: Find and replace events in log file

Discussion in 'Perl' started by Luuk, Jan 14, 2011.

  1. Luuk

    Luuk Guest

    On 14-01-11 01:27, Jack B. Pollack wrote:
    > I am a complete newbie to this but was able to cobble together a logging
    > script that takes my string passed to the script
    > (www.mywebsite.com/test?SomeData) and appends it to the end of a file. So
    > basically now I am creating a long text file of logged data.
    >
    > This takes a long time to load into a browser as the file grows in size.
    > Since I am only logging about 20 decree events and don't care about the

    ^^^^^^
    discrete ?

    > history, just the last occurrence, I would like to modify the script to
    > replace the previous event with the same name if it already exists (or add
    > it if it is new)
    >
    > Eg.
    >
    > Event id 1 1-5-11 5:30:00
    > Event id 7 1-4-11 9:20:20
    > Event id 2 1-7-11 4:21:56
    > Event id 6 1-2-11 8:21:30
    >
    >
    > New event:: Event id 7 1-12-11 4:56:22
    >
    > This is currently getting tacked on to the bottom of the file. I would like
    > to detect that there is already an Event id 7 and replace it with the new
    > time stamp. Obviously if there is a new unique event I would like to append
    > it to the bottom of the file.
    >



    When i had knowledg about perl, i would create an array, and store the
    date/time values in the array

    a[1]="1-5-11 05:30:00";
    a[2]="1-4-11 09:20:20";

    this way its 'easy' to store a new event
    if (newdate>a[7]) { a[7]=newdate; }

    But i'm a more complete newbie to perl than you ;)

    --
    Luuk
    Luuk, Jan 14, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik_the_boss
    Replies:
    0
    Views:
    2,647
    Henrik_the_boss
    Nov 5, 2003
  2. Amratash
    Replies:
    0
    Views:
    520
    Amratash
    Apr 13, 2004
  3. unomystEz
    Replies:
    0
    Views:
    551
    unomystEz
    Nov 19, 2006
  4. AAaron123
    Replies:
    1
    Views:
    274
    Cowboy \(Gregory A. Beamer\)
    Oct 14, 2008
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    359
    Chris
    Aug 30, 2005
Loading...

Share This Page