timestamp in STDERR output

ben fitzgerald ben at bfitzgerald.co.uk
Fri Jun 30 08:46:08 BST 2006


On Jun 29, 2006 03:19 PM, David Cantrell <david at cantrell.org.uk> wrote:

> 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];
> }

hi thomas,

I'm trying to understand perl a little better here!

could you explain why you use untie here having used the typeglob to
make the STDERR filehandle local to the block?

does this have a similar effect to select in this case as you print to
the default filehandle?

thanks very much,

ben.



More information about the london.pm mailing list