I'm running into an annoyance that I find rather purplexing. Maybe it is the fact that the closer I get to my wedding, the more my brain is shutting down that I can't seem to see the problem. :-p
I open the STDERR descriptor in a local block and redirect it to a variable. The first time I call it, it works fine. The second time, I get an uninitiallized value error
Use of uninitialized value in open at ./test_stderr line 10.
#!/usr/bin/perl use strict; use warnings; sub test_stderr { my $output; { open local(*STDERR), '>', \$output; } print $output if $output; } test_stderr; test_stderr;
open local(*STDERR), '>', \$output; <--- line 10
The STDERR descriptor is getting closed but wouldn't wrapping it in local() only affect the STDERR within the block? This is obviously a scope question...
Any clues for the clueless me?
No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
In reply to stderr, local block and redirection by jfroebe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |