#!C:\Perl\bin\perl.exe -w $file = 'foo.txt'; open(SESAME, $file); @lines = ; close(SESAME); $total = @lines; for ($i=0; $i <= $total; $i++) { if ($lines[$i] eq "\n") # This is line the line { pop @lines; $i = $i -1; $total = @lines; } } print "There are $total records in $file\n";