Printing to multiple files ... without changing my code.

McGlinchy, Alistair Alistair.McGlinchy at marks-and-spencer.com
Fri Sep 15 16:20:37 BST 2006


Joel Bernstein wrote:
> I'd say the best way is to tie 
> STDOUT, which I've just hacked up a demo of:

I didn't know you tie a file handle. Very cool!  

There's a wee bit of a performance hit using this method but well worth
the effort.

Benchmark: timing 10 iterations of normal, tied...
    normal:  9 wallclock secs ( 7.55 usr +  0.20 sys =  7.75 CPU) @
1.29/s (n=10)
      tied: 19 wallclock secs (17.41 usr +  0.16 sys = 17.56 CPU) @
0.57/s (n=10)

... Ooh and I can do this with any file handle. This opens up several
possibilities. My log files will never know what's hit them. Buahahahar!

Thanks for the great example.

Cheers

Alistair



**********************************************************************
Registered Office:
Marks and Spencer plc
Waterside House
35 North Wharf Road
London
W2 1NW

Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422
Facsimile (020) 7487 2670

<<www.marksandspencer.com>>

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and then delete it from your system; you should not copy, disclose, or distribute its contents to anyone nor act in reliance on this e-mail, as this is prohibited and may be unlawful.
2005





More information about the london.pm mailing list