if ($str =~ s/\A([^A-Ya-z])//ms) { # start with a letter
$first = sprintf('Z%02x', ord($1));
}
$str =~ s/([^A-Za-z0-9_\.\-])/$ESCAPES{$1}/egms;
if ($str =~ s/\A([^A-Ya-z])//ms) { # start with a letter
$first = sprintf('Z%02x', ord($1));
}
$str =~ s/([^A-Za-z0-9_\.\-])/$ESCAPES{$1}/egms;