count no. of lines in a file - Perl

count lines

Snippet Code


  
Rate this page :
  [ 1 votes]

#!/usr/bin/perl print "content-type:text/htmlnn"; $lines = 0; open(FILE, "test.txt") or die "Can't open `$filename': $!"; while (sysread FILE, $buffer, 4096) { $lines += ($buffer =~ tr/n//); } close FILE; print $lines;

Tags


Ask Questions

Ask Question