I'm trying to amend someone elses script and having problems with a bit that redirects STDOUT. In particular I want to be able to switch off the redirect.
The script looks like
I went on the CPAN doucmentation site and cut and pasted their example from the 'open' section into a test script which looks like
but when I run the test script I get
I've read TFM, and even cut and pasted from it. What am I doing wrong?
Thanks
Ceci n'est pas une signature
Columb Healy
The script looks like
Code:
$REPORT = "$SECURE/result.$$"; # global!
open (REPORT, ">$REPORT") || die "can't create $REPORT: $!\n";
# assume dups work
if ( $SHOW_OUT == 0 )
{
open (STDOUT, ">&REPORT");
open (SAVERR, ">&STDERR");
open (STDERR, ">&STDOUT");
}
Code:
#!/bin/perl -w
use strict;
open my $oldout, ">&STDOUT" or die "Can't dup STDOUT: $!";
open STDOUT, ">col.out" or die;
print "To file\n";
open STDOUT, ">&", $oldout or die "Can't dup \$oldout: $!";
print "To Screen\n";
Code:
g03201# ./test.pl
Unknown open() mode '>&' at ./test.pl line 7.
Thanks
Ceci n'est pas une signature
Columb Healy