http://www.perlmonks.org?node_id=761559

Count chars from STDIN, takes 1 command line argument that lists all characters to be counted. RegExp does all of the work
use re 'eval';$#ARGV<0&&exit 1;$s.=$_ while<STDIN>;$s=~/(?{$z=quotemeta shift@ARGV})((??{"[$z]"})(?{$c++})|.)*(?{print$c})/m;