Subject: | Object::Remote->connect() messes with *ARGV |
I was running code looking like this:
my $conn = Object::Remote->connect('-');
while (<>) {
Some::Class->new::on($conn, $_)->doit();
}
but to my surprise the body of the loop was never executed, even though I passed some data on stdin.
After some debugging I am able to work around the problem by putting the call to Object::Remote->connect() into a scope where I localize *ARGV. As one liners this fails my expectations:
$ echo foo | perl -MObject::Remote -e 'Object::Remote->connect("-"); print for <>'
$
whereas this works as expected:
$ echo foo | perl -MObject::Remote -e '{ local *ARGV; Object::Remote->connect("-"); } print for <>'
foo
$
Some digging around the code leads me to line 126 of Object::Remote::FatNode:
my %files = map +($mods{$_} => scalar do { local (@ARGV, $/) = ($_); <> }),
@non_core_non_arch, @core_non_arch;
Adding localization of *ARGV in here seems to solve the problem
my %files = map +($mods{$_} => scalar do { local *ARGV; local (@ARGV, $/) = ($_); <> }),
@non_core_non_arch, @core_non_arch;