Jack B. Nymbol has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; close(STDOUT); close(STDIN); close(STDERR); my $strout; my $strin; my $strerr; open(STDOUT, "+<", \$strout) or die; open(STDIN, "+<", \$strin) or die; open(STDERR, "+<", \$strerr) or die; print STDOUT "Hello this is 1 stdout\n"; print STDERR "Hello this is 1 stderr\n"; print STDIN "Hello this is 1 stdin\n"; system("fin . -name asasdasdasd"); print STDOUT "Hello this is 2 stdout\n"; print STDERR "Hello this is 2 stderr\n"; print STDIN "Hello this is 2 stdin\n"; close(STDOUT); close(STDIN); close(STDERR); open(LOG, ">log") or die; print LOG $strout, $strin, $strerr; close(LOG);
cat log Hello this is 1 stdout Hello this is 2 stdout Hello this is 1 stdin Hello this is 2 stdin Hello this is 1 stderr Hello this is 2 stderr
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing to a scalar -- STDIN, STDOUT, STDERR
by almut (Canon) on May 27, 2009 at 23:33 UTC | |
|
Re: printing to a scalar -- STDIN, STDOUT, STDERR
by ikegami (Patriarch) on May 28, 2009 at 00:20 UTC | |
by Jack B. Nymbol (Acolyte) on May 28, 2009 at 03:01 UTC | |
by ikegami (Patriarch) on May 28, 2009 at 03:07 UTC | |
|
Re: printing to a scalar -- STDIN, STDOUT, STDERR
by ig (Vicar) on May 28, 2009 at 00:25 UTC |