$returned_param =~ s/\d//g; # what you have now $returned_param =~ s/\d+$//; # what I think you might want instead