Hi,
I want to write a perl script to count the number of character(case insensitive) in a file.
let me know if this is write way to do this.
Thanks & Regards
Chendil
I want to write a perl script to count the number of character(case insensitive) in a file.
let me know if this is write way to do this.
Code:
open(IN,"words.txt");
$count=0;
$char="a";
$char=lc($substr);
$char2=uc($substr);
while(<IN>)
{
$result= rindex($_,$char,length($_));
$result2= rindex($_,$char2,length($_));
while($result!=-1)
{
$count=$count+1;
$result=rindex($_,$char,$result-1);
}
while($result2!=-1)
{
$count=$count+1;
$result2=rindex($_,$char2,$result2-1);
}
}
print $count."\n";;
close(IN);
Chendil
Comment