in reply to Globs and globals
The easiest way might be to just localize S1 and S2 first:
local(*S1, *S2); ...as in your first example...
OTOH, I don't think my $socket \*S1 is valid Perl--maybe there's an equal sign missing between $socket and \*S1?
There is no sig.