Printing to multiple files ... without changing my code.
Dan Rowles
d.rowles at outcometechnologies.com
Fri Sep 15 15:58:48 BST 2006
Would you be willing to replace your print statements with something
like Log::Log4perl?
Much more heavyweight than just using print, but *very* flexible :)
Dan
McGlinchy, Alistair wrote:
> Hi all,
>
> I have some code with print statements liberally sprinkled throughout
> (180 locations at last count). I now need to have this code write to a
> production and development box every time it runs. It's likely that the
> number of locations could grow so can someone please advise what is the
> standard idiom for making my standard "print"s go to multiple files?
>
> I know I can roll my own "tee" sub, I just want to know if there's a way
> of doing this without having to change all the print throughout my code
> to my_tee statements.
>
> I've also seen IO::Tee on CPAN but that will also require changing my
> code ... won't it?
>
> my @files = qw( pie.txt pony.txt buffy.txt);
> my @handles = map {open my $x, ">>$_" or die $!; $x} @files;
> #... <magic>...
> print "Hello\n"; #Magically written to all @files
> close $_ for @handles;
>
>
> 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
>
>
--
Dan Rowles
Outcome Technologies
_________________________________
t: +44 (0)207 656 2460
f: +44 (0)709 230 6588
m: +44 (0)798 076 8143
e: d.rowles at outcometechnologies.com
w: http://www.outcometechnologies.com
BUPA House
15-19 Bloomsbury Way
London WC1A 2BA
_________________________________
***This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you receive this message in error, please return it to the
sender.***
More information about the london.pm
mailing list