#!/usr/bin/perl -w

use strict;

#We capture the first argument from the command line.... this will be the
#path to the file we want to read
my $INPUTFILE = $ARGV[0];

main();


sub main {

    #using the open function, we asign the filehandle ASN1 to the file we 
    #specified on the command line....  if this does not open, we use the 
    #function die() to halt progress of the script and tell us something is 
    #wring
    open(ASN1,"$INPUTFILE") or die("Can't open: $INPUTFILE\n\n");


    my $ctr = "1";

    #Using the diamnond operator on the filehandle ASN1 will return each line 
    #of the file.
    #We put the diamnod operator in the () of the while loop.
    #The effect this has, is the while loop will execute until there are no more
    #lines returned by the diamnond operator.
    while (<ASN1>) {
	my $line = $_; #similar to @_, the $_ is a special varaible.
	#It is assigned any value which is returned from the diamnod operator
	#in the () of the while loop.  

	#since the <> returns the whole line, we want to 
	#remove the newline
	chomp($line); 

	#we can print each line of the file. i am adding [$ctr] to the front of
	#each line to make it clear we are printing each line
	print "[line# $ctr\] $line\n";


	++$ctr;
    }

    print "\n========\nthe file had $ctr lines.\n\n";

    #use close() to close any filehandles you have opened
    close(ASN1);

}

