1.

Given A File, Count The Word Occurrence (case Insensitive)?

Answer»

open(FILE,"FILENAME");
@ARRAY=; $WOR="word to be found";
$count=0; FOREACH $line (@array) { @arr=split (/s+/,$line);
foreach $word (@arr) { if ($word =~ /s*$WORS*/i) $count=$count+1; } }

print "The word occurs $count times";

open(FILE,"filename");
@array=; $wor="word to be found";
$count=0; foreach $line (@array) { @arr=split (/s+/,$line);
foreach $word (@arr) { if ($word =~ /s*$wors*/i) $count=$count+1; } }

print "The word occurs $count times";



Discussion

No Comment Found