# Break up line into words, more or less, and pull out first word of each line.
# 1st argument: name of input file
# 2nd argument: name of output file

if ( scalar( @ARGV ) >=  2 )
{ 
            $TheFile = $ARGV[0];
            $TheMainOutFile = ">" . $ARGV[1];

} 

else 

{ 	print  "Not enough arguments given to operate; goodbye."; 
	exit;
}


open (INFILE, $TheFile) or die "The file $TheFile could not be found";
open (OUTFILE, $TheMainOutFile);
 


$LineCount =0; 					#This is unnecessary in PERL;

while (<INFILE>)        
{
	$LineCount =  $LineCount + 1;
	$TheLine= $_;				# unnecessarily explicit in real PERL
    	chomp ($TheLine); 			# Removes the final carriage-return of the line.

	@Words=split(/ /, $TheLine); 		# Split each line up where there is a space
						# and call this @Words;
	$FirstWord = shift ( @Words ); 		# pull out the first word of each line, 
						# and call it $FirstWord;
	print OUTFILE "\n$LineCount  $FirstWord";	 
	print         "\n$LineCount  $FirstWord";	 
                 
}


close INFILE;
close OUTFILE;

#	Now run this program, and keep your finger on Control-S, so you can pause it (and
#	restart it, watching its output on the screen.







