IMHO, it would make sense to encapsulate everything in a subroutine along the lines of
use strict; use warnings; sub tprint { my $msg = join $,//'' ,@_; my $tstamp = localtime()." "; $msg =~ s/^/$tstamp/gm; print $msg; } tprint "something\nelse\n";
BUT to completely replicate the interface of the print function is beyond my Perl skills. I have no idea how one could now provide a file handle to print into file.
In reply to Re^3: Appending time to each line
by hdb
in thread Appending time to each line
by ajose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |