in reply to Students Rank calculation for the below perl script

If there is a chance that the header line might be repeated further down your data file, ignore this post.

If, on the other hand, your header line only occurs at the top of the data file, just read and discard the header outside the loop and get rid of the test next if $line=~/^NAME/; which you will be doing un-necessarily on every data line. (I wonder if there is anybody with a surname of 'Name'.)

my $marksFile = q{marks.txt}; open my $marksFH, q{<}, $marksFile or die qq{open: $marksFile: $!\n}; { my $header = <$marksFH>; } while ( my $line = <$marksFH> ) { chomp $line; ... }

I hope thisis of interest.

Cheers,

JohnGG