Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Redirecting STDOUT, lexically scoped

by radiantmatrix (Parson)
on Jul 31, 2007 at 14:51 UTC ( [id://629842]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Redirecting STDOUT, lexically scoped
in thread Redirecting STDOUT, lexically scoped

Do you understand why? The leading * is there because you're localizing the typeglob. As a result, you'll also effectively localize any $STDOUT, @STDOUT, or %STDOUT you may have defined.

Not likely to be a problem, but something that bit me at least once as a novice... ;-)

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Replies are listed 'Best First'.
Re^4: Redirecting STDOUT, lexically scoped
by mfwitten (Initiate) on Apr 11, 2009 at 02:29 UTC
    You don't have to clobber the whole typeglob. Read about the "*foo{THING} notation, and consider this:
    use strict; use warnings; open my $a, ">", "$ENV{HOME}/blahblahblah"; my @STDOUT = (0, 1, 2, 3); { local *STDOUT; print "It doesn't matter, because you'll get a warning\n"; } { local *STDOUT = $a; @STDOUT = ('a', 'b', 'c', 'd'); print "Inside Block @STDOUT\n"; } print "Outside Block\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://629842]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-03-28 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found