-------------------------------------------------------------------------------- #!/usr/local/bin/perl use strict; use warnings; my $count=0; open(FILE, "C:/Perl/testfile.txt"); while() #count the total words { $count++ while m/[a-zA-Z]\w*/g;} print "total word = $count \n"; --------------------------------------------------------------------------------