in reply to Using pipe and reading from the stdin

I use something like that every day -- I have a script called notch.pl that outputs a blank line and the time after a new line of output arrives if it's a different minute that the previous line's time.

Here's the code:

#!/usr/bin/perl -w # Notch out time when lines from 'tail -f' arrive so that lines # from different minutes are separated by a timestamp. use strict; { my $lastMinute = (localtime)[1]; while(<>) { my $thisLine = $_; my $thisMinute = (localtime)[1]; if ( $thisMinute != $lastMinute ) { $lastMinute = $thisMinute; print "\n"; print scalar localtime; print "\n"; } print $thisLine; } }
I probably could use File::Tail as merlyn suggests but just threw it together because trying to readh read the tail of a log file is head hard enough -- this just breaks it up a little.

Based on the amount of traffic that I see, I don't worry too much about it using an extra pipe or process.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Update Correct two typos .. the first of which I made again, and had to go back and fix again.