in reply to Monk Specs.?

In terms of a code review, I can give you the following suggestions and comments. So if I were rewriting the code, I'd say
while ( <LOG> ) { if ( /$date/ ) { print LOG_FILE <LOG>; } # UPDATED }
What does this code do? If the target date is found while looking through the log file, print the remainder of the log file. The print will continue until the file runs out. At that point the loop will continue, but the log file has run out, and the loop will exit. (This assumes that the data is sorted!)

Study hard. :)

--t. alex

"Of course, you realize that this means war." -- Bugs Bunny.

Update: Added LOG_FILE file handle that was missing from the original post, as indicated by replies after this note.

Replies are listed 'Best First'.
Re:x2 Monk Specs.?
by grinder (Bishop) on Jan 16, 2002 at 19:39 UTC
    What does this code do? If the target date is found while looking through the log file, print the remainder of the log file.

    Note quite. As soon as the date changes, your script as it stands will stop printing additional lines to the other logfile (which, according to the initial script, is addressed by the LOGFILE file handle). You are printing the records back into the original logfile!

    I ++ you anyway, because apart from that your advice is faultless.

    --
    g r i n d e r
    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u';
      Eeyow. I hate when that happens. OK, I change that line to print LOG_FILE <LOG>; My heart was in the right place. :)

      --t. alex

      "Of course, you realize that this means war." -- Bugs Bunny.

Re: Re: Monk Specs.?
by particle (Vicar) on Jan 16, 2002 at 19:43 UTC
    um... your points are valid, but this code is incorrect. *ducks*

    while ( <LOG> ) { if ( /$date/ ) { print <LOG>; } }
    firstly, you're reading from and printing to the same filehandle, probably a typo. it should print LOGFILE;. secondly, it's only printing lines that match the date, instead of printing all lines from the matched date until the end of the file.

    ~Particle

      Hmm .. don't think my code is wrong. The if statement watches for the correct date, and when that date's found, the entire rest of the file is output. My original reply had output going to STDOUT, but I later fixed that so it went to LOG_FILE, as in the original post. The input file handle is LOG.

      --t. alex

      "Of course, you realize that this means war." -- Bugs Bunny.

Re: Re: Monk Specs.?
by jdporter (Paladin) on Nov 05, 2002 at 15:30 UTC
    What was that admonition about sucking immense log files into memory?

    And what does this do?

    print LOG_FILE <LOG>;

    How about:
    print LOG_FILE while <LOG>;