#  RedirectedFileWriting.pl
#  Example: 7.21
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script redirects STDOUT to another file handle.

if( open( FILE, "> test.txt" ) )
{
  open( STDOUT_BACKUP, ">&STDOUT" );
  open( STDOUT, ">&FILE" );
  print "Hello there!\n";
  open( STDOUT, ">&STDOUT_BACKUP" );
  close( STDOUT_BACKUP );
  close( FILE );
}
