use strict; my $str='abc%def%.%'; #Get the count by removing all but the percent sign my $pstr=$str; $pstr=~s/[^\%]//sg; my $pcount=length($pstr); print "str: $str\n"; print "pstr: $pstr\n"; print "pcount: $pcount\n";
-------------------------------
by me
http://www.basgetti.com
http://www.kidlins.com
In reply to Counting how many times a character is in a string. by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |