#  StreamDump.pl
#  Example 3.7:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script will simply read a file and dump it to the 
#  the screen. It supports alternate data streams. This can be
#  used as a "alternate data stream" aware version of the 
#  DOS type command.
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


foreach my $Mask ( @ARGV )
{
  my @List;

  # Must be careful since glob() does not support
  # paths with embedded spaces.
  if( @List = glob( $Mask ) )
  {
    push( @FileList, @List );
  }
  else
  {
    push( @FileList, $Mask );
  }
}
foreach my $Path ( @FileList )
{
  print $Path, "\n";
  print "-" x length( $Path ), "\n";
  if( open( FILE, "< $Path" ) )
  {
    my $Buffer;

    binmode( FILE );
    while( read( FILE, $Buffer, 1024 ) )
    {
      print $Buffer;
    }
    close( FILE );
  }
  else
  {
    print "\tError: $!\n";
  }
  print "\n";
}
