Don't do that!
FILTER_ONLY will always have bugs. Just don't use it! It is really just that simple.
And the problem mysteriously goes away.
Yes. Didn't you learn anything from people's attempt to use Switch.pm?? Things mysteriously break (and mysteriously unbreak). Just STOP IT!
You actually can write reasonable source filters for Perl. You just need to avoid trying to not have your filter apply to quoted things (or other subsets of Perl syntax). So define your own way to escape things for places when the filter would be a pain. And define your custom syntax so you don't need to escape away from it much.
And never, never use FILTER_ONLY!