in reply to Re^2: reading file
in thread reading file

I could think of this very simple code, it gives you an idea about creating a list, that list is saved in @array and then for each element in the array there happens a match check that increments the count when true, you have each element checked and the checking goes on till all the array elements have been checked for the pattern /\bsaravanan\b/ ...
!/usr/local/bin/perl $string="a student name is sa\nravanan. saravanan is studying 3rd stan +dard.i am go with sara\nvanan"; $count = 0; $string =~s/\n//g; #removing \n print "$string\n"; @array = split(" ", $string); #making the string into individual +list elements foreach $element(@array){ if($element=~/\bsaravanan\b/){ $count++; } } print "found: $count matches.\n";
Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind