From: Radu Greab Date: Mon, 6 May 2002 04:23:10 +0000 (+0300) Subject: Re: [ID 20020504.006] $s=`command` fails if $/=\integer X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fa326138e0db34ae4a0161fbe7c05eb9a9367825;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20020504.006] $s=`command` fails if $/=\integer Message-ID: <15573.56062.264379.981864@ix.netsoft.ro> p4raw-id: //depot/perl@16421 --- diff --git a/pp_sys.c b/pp_sys.c index 0183325..c55f0a4 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -321,10 +321,13 @@ PP(pp_backtick) ; } else if (gimme == G_SCALAR) { + SV *oldrs = PL_rs; + PL_rs = &PL_sv_undef; sv_setpv(TARG, ""); /* note that this preserves previous buffer */ while (sv_gets(TARG, fp, SvCUR(TARG)) != Nullch) /*SUPPRESS 530*/ ; + PL_rs = oldrs; XPUSHs(TARG); SvTAINTED_on(TARG); } diff --git a/t/op/exec.t b/t/op/exec.t index 3edbc6a..5f110be 100755 --- a/t/op/exec.t +++ b/t/op/exec.t @@ -19,7 +19,7 @@ my $Is_Win32 = $^O eq 'MSWin32'; skip_all("Tests mostly usesless on MacOS") if $^O eq 'MacOS'; -plan(tests => 20); +plan(tests => 21); my $Perl = which_perl(); @@ -74,6 +74,12 @@ is( $echo_out, "ok\n", 'piped echo emulation'); is( scalar `$Perl -le "print 'ok'" | $Perl -e "print "`, "ok\n", 'extra newlines on outgoing pipes'); + + { + local($/) = \2; + $out = runperl(prog => 'print q{1234}'); + is($out, "1234", 'ignore $/ when capturing output in scalar context'); + } }