perl: better handling of dollar-hash prefix
perl: fix bugs in s///, tr///, y///