anaconda_wly has asked for the wisdom of the Perl Monks concerning the following question:
&main; sub main() { my @mylist = qw(a, b, c); foreach(@mylist) { &fun($_); print "changed:\$_ $_\n"; } } sub fun() { my $ret = open(STATUS, "echo d-e-f|"); while(<STATUS>){ if(/d-e-f/){ close(STATUS); return; } } close(STATUS); } output not a,b,c: changed:$_ d-e-f changed:$_ d-e-f changed:$_ d-e-f
Why $_ is changed?? Anyone know that? I'm going to read something from the pipe.
Is there any safer/simple way to "system"/run a command and get its output into a variable?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Very curious Problem...
by LanX (Saint) on Jan 23, 2013 at 09:06 UTC | |
by anaconda_wly (Scribe) on Jan 23, 2013 at 09:38 UTC | |
by LanX (Saint) on Jan 23, 2013 at 10:17 UTC | |
by Anonymous Monk on Jan 23, 2013 at 10:21 UTC | |
by anaconda_wly (Scribe) on Jan 23, 2013 at 09:18 UTC | |
Re: Very curious Problem...
by vinoth.ree (Monsignor) on Jan 23, 2013 at 09:09 UTC | |
Re: Very curious Problem...
by muba (Priest) on Jan 23, 2013 at 12:06 UTC | |
by anaconda_wly (Scribe) on Jan 23, 2013 at 15:17 UTC | |
Re: Very curious Problem...
by CountZero (Bishop) on Jan 24, 2013 at 07:31 UTC |
Back to
Seekers of Perl Wisdom