#  StreamRead.pl
#  Example 3.6:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script read two streams from a test file. This script
#  assumes that the StreamWrite.pl script has already been 
#  run.
#  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  "This is the main data stream for $File.\n";
  while( my $Line = <STREAM1> )
  {
    print $Line;
  }
  close( STREAM1 );
  
  if( open( STREAM2, "< $File:$Stream" ) )
  {
    print "\n\nThis is the data stream $File:$Stream:\n";
    while( my $Line = <STREAM2> )
    {
      print $Line;
    }
    close( STREAM2 );
  }
  else
  {
    print "Error: $!\n";
  }
}
else
{
  print "Error: $!\n";
} 
