#!/usr/local/bin/perl # #counts the number of lines that the file in $ARGV[0] contains # How many lines hmlines filename: # $|=1; $lines=0; $buffer = ""; die "No File Name" if !$ARGV[0]; $filename = $ARGV[0]; open (FILE , $filename)||die "Can't open `$filename`:$!"; while (sysread FILE, $buffer, 4096){ $lines += ($buffer=~ tr/\n//); } print ("the file ",$filename," contains ",$lines," lines","\n"); close FILE;