I can think of a few approaches...

1. write a subroutine to do this.
2. write a source filter
(http://www.samag.com/documents/s=1287/sam03030004/)
3. use tie

I would probably choose the third.  It is possible to create a module that
you simulate a filehandle (or hash, or array, etc).  The short of it is that
your module will "intercept" prints to the filehandle and do whatever it
wants with them, including printing to a file and STDOUT.  Check out
perltie, it explains it better than I ever could
(http://www.perldoc.com/perl5.6.1/pod/perltie.html)

Rob

-----Original Message-----
From: Cutts III, James H. [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 07, 2002 9:16 AM
To: [EMAIL PROTECTED]
Subject: Printing to 2 destinations with one statement in Windows


I am using ActiveState Perl v5.6.1 build 631 for a bunch of different
projects.  I keep coming up with the same need in most of my programs.  I
would like to be able to direct output to both the screen and a file without
having to use pairs of print statements.

The code:
        print LOG_FILE "something useful here";
        print "something useful here";
quickly becomes challenging to manage and gets long quickly.  (I wouldn't
mind if I were paid by the line.)

I would like is to have a file handle to the file and a file handle to the
file and STDOUT combination.  This would allow me to send everything that
goes to the console to the file, but also be able to send lines directly to
the file without going to the console.  Is this possible or am I just being
lazier than the standard PERL programmer.

Thanks for your help.
----------------------------------------------------------------------------
------------
James H. Cutts III                Integrated Technology Services
Computer Project Manager      Research and Education Support
Phone: (573) 882-6181         University of Missouri - Columbia
FAX:   [573] 884=8192         DC017.00,  265H Quarterdeck
                                         Columbia, MO  65212

E-Mail: [EMAIL PROTECTED]


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to