use strict; use warnings; use Data::Dumper; my ($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,$isdst)=localtime(time); my $table; my $log = 'log_file.txt'; open my $fh, '>>', $log or die "Can't open $log : $!"; while (<$fh>) { my $comment = ; chomp $comment; 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;