# convert medial capital into capital separated by "_" $str =~ s/([a-z]+)/sprintf(uc($1)."_")/ge; $str =~ s/_$//;