#Count number of lines in a file $filename = <@ARGV>; $lines = 0; open(FILE, $filename) or die "Can't open `$filename': $!"; while (sysread FILE, $buffer, 4096) { $lines += ($buffer =~ tr/\n//); } close FILE; print "The number of lines in $filename is $lines.\n";
In reply to Count number of lines in a text file by Scott7477
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |