in reply to SIG PIPE

Does your code open a pipeline file handle? When it runs, is it reading stdin from a pipe, or writing stdout to a pipe on the shell command line?

It wasn't clear from your description, but are your "local blocks" trying to do something like:

local %ENV; $ENV{FOO}="BAR";
I'm not even sure whether this will run or generate some sort of error on its own, but I'd worry that the resulting behavior might not be what you'd expect -- I just don't know for sure, and I'm not sure what the appropriate test would be. (That is left as an exercise...)