in reply to using tr

$quality =~ tr/[\!-\*][\+-4][5-\>][\?-\~]/0123/;

tr doesn't do character classes.  The two strings specify lists of characters (with ranges allowed) that must correspond. For example, to replace A-D with 1 and F-H with 2, you'd say

tr/A-DF-H/1111222/;