in reply to script for adding timestamp to stdin
use strict; use warnings; use Data::Dumper; my $table; my $log = 'log_file.txt'; open my $fh, '>>', $log or die "Can't open $log : $!"; while (<STDIN>) { my $comment = $_; chomp $comment; my ($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,$isdst)=localtime(time); printf "%4d-%02d-%02d %02d:%02d:%02d\t", $year+1900,$mon+1,$mday,$hour,$min,$sec; print $comment . "\n"; printf $fh "%4d-%02d-%02d %02d:%02d:%02d\t", $year+1900,$mon+1,$mday,$hour,$min,$sec; print $fh $comment . "\n"; } close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: script for adding timestamp to stdin
by Anonymous Monk on Jun 02, 2010 at 18:42 UTC | |
by almut (Canon) on Jun 02, 2010 at 19:10 UTC | |
by Anonymous Monk on Jan 20, 2012 at 15:45 UTC |