summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp_hot.c7
-rwxr-xr-xt/op/tiehandle.t14
2 files changed, 18 insertions, 3 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 8f042b9343..8e36c8a9f5 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1490,8 +1490,11 @@ Perl_do_readline(pTHX)
call_method("READLINE", gimme);
LEAVE;
SPAGAIN;
- if (gimme == G_SCALAR)
- SvSetMagicSV_nosteal(TARG, TOPs);
+ if (gimme == G_SCALAR) {
+ SV* result = POPs;
+ SvSetSV_nosteal(TARG, result);
+ PUSHTARG;
+ }
RETURN;
}
fp = Nullfp;
diff --git a/t/op/tiehandle.t b/t/op/tiehandle.t
index 257a613958..818cecf185 100755
--- a/t/op/tiehandle.t
+++ b/t/op/tiehandle.t
@@ -77,7 +77,7 @@ package main;
use Symbol;
-print "1..39\n";
+print "1..40\n";
my $fh = gensym;
@@ -230,3 +230,15 @@ ok($r == 1);
Implement::compare(PRINT => @received);
}
+{
+ # [ID 20020713.001] chomp($data=<tied_fh>)
+ local *TEST;
+ tie *TEST, 'CHOMP';
+ my $data;
+ chomp($data = <TEST>);
+ ok($data eq 'foobar');
+
+ package CHOMP;
+ sub TIEHANDLE { bless {}, $_[0] }
+ sub READLINE { "foobar\n" }
+}