timestamp in STDERR output

Thomas Busch tbusch at cpan.org
Thu Jun 29 15:45:08 BST 2006


many thanks. That's exactly what I wanted. I owe you a beer.

thomas.

> On Thu, Jun 29, 2006 at 04:02:46PM +0200, Thomas Busch wrote:
> 
> > is it possible to redefine STDERR in such a way that
> > you get a timestamp at the beginning of each line ?
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> use Tie::STDERR \&timestamper;
> 
> sub timestamper {
>     local *STDERR;
>     untie *STDERR;
>     print time().': '.$_[0];
> }
> 
> warn "now with timestamps!\n";
> 
> -- 
> David Cantrell | http://www.cantrell.org.uk/david
> 
> Computer Science is about lofty design goals and careful algorithmic
> optimisation.  Sysadminning is about cleaning up the resulting mess.
> 





More information about the london.pm mailing list