DarkLord1 has asked for the wisdom of the Perl Monks concerning the following question:
I have been working my way through several sections of Peter Wainwright's "Pro Perl." I was, in particular, interested in his approach to redirecting Perl's STDOUT and STDERR filehandles. I entered his code (see below) and got an odd result that I don't understand and, after researching it, can't find any indication of what is going on.
Here is the code snippet:
open(OLDOUT, "> &STDOUT"); my $logfile = 'MyLearn01_log.txt'; open(STDOUT, "> $logfile"); select STDOUT; <...do whatever printing to the new STDOUT...> close(STDOUT); open(STDOUT, "> &OLDOUT);
When I run this snippet I found that a file &STDOUT had been created, as well as the $logfile, MyLearn01_log.txt.
I understand, of course, why the logfile was created. But I don't understand why the file, &STDOUT, was created.
The book doesn't say anything about it (in fact my read is that no such thing should have happened).
I am running version 5.8.8.819 of ActiveState's Perl (I haven't upgraded to 5.10 yet since my IDE doesn't yet support it) under Windows XP.
Does anyone know why &SDTOUT is created?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Pro Perl's" Redirecting Filehandles - Unexpected Result (space)
by tye (Sage) on Jan 16, 2008 at 04:37 UTC | |
by ack (Deacon) on Jan 18, 2008 at 04:47 UTC | |
by tye (Sage) on Jan 18, 2008 at 21:55 UTC | |
by DarkLord1 (Novice) on Jan 19, 2008 at 05:17 UTC | |
by tye (Sage) on Jan 19, 2008 at 06:19 UTC | |
| |
by parv (Parson) on Jan 19, 2008 at 05:40 UTC |