First of all, don't use "|
" as a boolean operator. It is not, it is a bitwise operator. Use "||
" instead, for booleans.
And second... why aren't you trying to match just 'b', 'z' or 'y' characters, instead of absolutely anything? That's what regular expressions are for!
$str =~ s/([bzy])//g;
p.s. The capturing parens aren't necessary, but perhaps you may have a use for them yet, so I let them in... But, for this code snippet, you can leave them out. The replacement will probably be faster for it.
$str =~ s/[bzy]//g;