print_a_file.pl
#!/usr/local/bin/perl
# 28 juni 2003, by jan croonen.
# demo that uses MSComDlg.CommonDialog

use strict;
use OLE;

my $myfile = getfile();
sub getfile (){
      my $dirfilter = "Tekst (*.txt)|*.txt|HTML (*.htm)|*.htm|ASP (*.asp)|*.asp|Alle bestanden(*.*)|*.*";
      return SelecteerBestand(
      "", "Bestand selecteren", $dirfilter, 1, 0
      );
}
sub SelecteerBestand(){
      my ($dir, $titel, $filter, $index, $schakelopties) = @_;
    my $dialoog = CreateObject OLE "MSComDlg.CommonDialog"
    || die "CreateObject: $!";
    $dialoog->{Filter} = $filter;
    $dialoog->{FilterIndex} = $index;
    $dialoog->{Flags} = $schakelopties;
    $dialoog->{MaxFileSize} = 260;
    $dialoog->{CancelError} = 0;
    $dialoog->{DialogTitle} = $titel;
      $dialoog->{InitDir} = $dir;
    $dialoog->ShowOpen();
    $schakelopties = $dialoog->{Flags};
    ($dialoog->{FileName});
}

unless (open (INFILE, $myfile)) {
      die "$0: kan IN: '$myfile' niet openen, $!\n";
}
print "printing: $myfile\n\n";

while( <INFILE> ){
      print;
}

unless (close (INFILE)) { die "sluitfout $myfile: $!\n";}
print "\nDruk op Enter";
<STDIN>; # wait
print "\n";