use strict; use warnings; my $str='abc%def%.%'; printf "pcount: %d\n", split(/%/, $str.' ')-1;