$numHeaders= $ARGV[0]; $numFooters= $ARGV[1]; # Read the file into memory open (INPUT, $l_infile); my @file = ; close INPUT; # Treating the array as a scalar value gives you the number of lines # (not that you really need to worry about this right now) my $numLines = @file; # Split the headers and footers into their own arrays my @headers = splice @file, 0, $numHeaders; my @footers = splice @file, $#file-$numFooters, $numFooters; for my $line (@headers) { # do whatever you want with the headers } for my $line (@file) { # process your data } #### # Discard the headers and footers splice @file, 0, $numHeaders; splice @file, $#file-$numFooters, $numFooters;