$ans = eval "\$str =~ tr/$SrchStr/$SrchStr/"; die $@ if $@;
Update: If you want to count slashes, define $SrchString as '\/', or use a separator other than / for tr. Thanks to Corion for reminding me to point this out.
the lowliest monk
In reply to Re: Capturing occurrence counts via tr/// with variable interpolation
by tlm
in thread Capturing occurrence counts via tr/// with variable interpolation
by KenW
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |