#  StreamWrite.pl
#  Example 3.5:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script creates a test file and populates both the
#  main data stream as well as an alternative stream.
#  THIS SCRIPT REQUIRES AN NTFS PARTITION.
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


$File = "StreamTest.txt";
$Stream = "AltDataStream";
if( open( STREAM1, "> $File" ) )
{
  print "Writing to the main data stream.\n";
  print STREAM1 "\tWelcome to the main data stream.\n";
  close( STREAM1 );
  
  if( open( STREAM2, "> $File:$Stream" ) )
  {
    print "Writing to alternative stream '$Stream'.\n";
    print STREAM2 "\tWelcome to the alternative data stream '$Stream'\n";
    close( STREAM2 );
  }
  else
  {
    print "Error: $!\n";
  }
}
else
{
  print "Error: $!\n";
}
