fredo2906 has asked for the wisdom of the Perl Monks concerning the following question:
Thanks a lottail -f mylog.log | perl -e 'use POSIX qw( mktime );$l=0;$t=0;while(<S +TDIN>){if(/^(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}),(\d{3})/){ $o="$1 +$2"; @a = reverse split( "[-: ]", $1);$a[3]-=1;$a[4]-=1;$a[5]-=1900; +if(!$l){$t=mktime(@a,0,0,0)*1000+$2; $l=1;} else { $t2=mktime(@a,0,0, +0)*1000+$2;$e=$t2-$t;$t=$t2;$l=0;print "$o $e\n";}}}'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: One long liner to make it short
by Corion (Patriarch) on Feb 17, 2014 at 12:34 UTC | |
|
Re: One long liner to make it short
by hdb (Monsignor) on Feb 17, 2014 at 14:51 UTC | |
by fredo2906 (Acolyte) on Feb 17, 2014 at 15:14 UTC | |
|
Re: One long liner to make it short
by Bloodnok (Vicar) on Feb 17, 2014 at 14:45 UTC | |
|
Re: One long liner to make it short
by Anonymous Monk on Feb 17, 2014 at 14:46 UTC | |
|
Re: One long liner to make it short
by Anonymous Monk on Feb 17, 2014 at 16:30 UTC | |
by fredo2906 (Acolyte) on Feb 17, 2014 at 23:49 UTC |