in reply to removing a character from a string

A simple way to do this is to use the substitution operator:
$x = "123-4567"; $x =~ s/-//g;
More generally, to remove all nondigit characters, use
$x =~ s/\D//g;

-Mark