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

Thanks, I was missing the *

Replies are listed 'Best First'.
Re^3: Redirecting STDOUT, lexically scoped
by radiantmatrix (Parson) on Jul 31, 2007 at 14:51 UTC

    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
      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";