Home > Archive > PERL Beginners > April 2007 > Switching io redirection between display and file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Switching io redirection between display and file
|
|
| Alok Nath 2007-04-26, 7:58 am |
| Hi ,
Can somebody help me out ?
I wanted to switch io redirection between log file and=20
standard display device.Basically sometimes I want to
print into a log file and other time to the display device.
To redirect I am using this=20
open (STDOUT, ">> TEST.log)=20
Two doubts here -
1. I don't know how to reset it to default i.e to point STDOUT
to display again.
2. Is there any better way of doing above ?
Thanks guys for all the help ...
AN.
=09
=09
| |
| Jeff Pang 2007-04-26, 7:58 am |
| 2007/4/26, Nath, Alok (STSD) <alok.nath@hp.com>:
> Hi ,
> Can somebody help me out ?
>
> I wanted to switch io redirection between log file and
> standard display device.Basically sometimes I want to
> print into a log file and other time to the display device.
>
> To redirect I am using this
>
> open (STDOUT, ">> TEST.log)
>
> Two doubts here -
> 1. I don't know how to reset it to default i.e to point STDOUT
> to display again.
> 2. Is there any better way of doing above ?
>
Hi,
Using "select" to do this thing is maybe better.
open FILE,">>",$logfile or die $!;
my $old = select FILE;
print "some things..."; # print to logfile
select $old; # select back to STDOUT
print "other things..."; # print to STDOUT
--
Chinese Practical Mod_perl book online
http://home.arcor.de/jeffpang/mod_perl/
| |
| Mumia W. 2007-04-26, 6:58 pm |
| On 04/26/2007 07:05 AM, Nath, Alok (STSD) wrote:
> Hi ,
> Can somebody help me out ?
>
> I wanted to switch io redirection between log file and
> standard display device.Basically sometimes I want to
> print into a log file and other time to the display device.
> [...]
"perldoc -f open" describes the technique.
|
|
|
|
|