#!C:/PROGRA~1/PERL/BIN/PERL.EXE -w
use strict;

#my $prog="last"; # the program to run
# last is a Unix command, use a DOS command when testing in Windows console mode
my $prog="dir";  # the program to run

my $line;
my $cnt=0;

open (FILE, "$prog |") or die "Cannot run $prog and get the pipe.";
while ($line=<FILE>)
{
    $cnt++; # I am sure that $cnt holds a number so I don't need $cnt=$cnt+1;
    print "$cnt\t$line";
}
close(FILE);

print "\n\n\nThe program $prog printed $cnt lines of data.\n";