in reply to Switching between output to file and STDOUT

if (defined $outfile) { open OUTPUT, '>', $outfile; select OUTPUT; } # then just use "print"

Update: Fletch is right. I've removed the misleading reference to STDOUT.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: Swiching between output to file and STDOUT
by Fletch (Bishop) on Nov 09, 2004 at 14:16 UTC

    And by "then just print to STDOUT" he means "just print without specifying a filehandle" (e.g. print "foo\n").

    Even if you change the default output handle with select OUTPUT the statement print STDOUT "foo" will still print to stdout.