http://www.perlmonks.org?node_id=11136461


in reply to -E behavior with stdin script

The module Modern::Perl addresses a similar issue. I do not know if you could use it, but its documentation may be helpful.
Bill