This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #123218] "preserve" $/ if set to a bad value
authorTony Cook <tony@develop-help.com>
Wed, 4 Feb 2015 05:10:20 +0000 (16:10 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 4 Feb 2015 05:10:20 +0000 (16:10 +1100)
and base/rs.t tests $/ not $!

mg.c
t/base/rs.t

diff --git a/mg.c b/mg.c
index 58427a4..237b404 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1105,6 +1105,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
     case ':':
        break;
     case '/':
+        sv_setsv(sv, PL_rs);
        break;
     case '[':
        sv_setiv(sv, 0);
index c81b2dc..6f3c4b5 100644 (file)
@@ -1,7 +1,7 @@
 #!./perl
-# Test $!
+# Test $/
 
-print "1..38\n";
+print "1..39\n";
 
 $test_count = 1;
 $teststring = "1\n12\n123\n1234\n1234\n12345\n\n123456\n1234567\n";
@@ -34,8 +34,13 @@ test_record(*TESTFILE);
 close TESTFILE;
 $test_count_end = $test_count;  # Needed to know how many tests to skip
 
+$/ = "\n";
+my $note = "\$/ preserved when set to bad value";
+# none of the setting of $/ to bad values should modify its value
 test_bad_setting();
-
+print +($/ ne "\n" ? "not " : "") .
+  "ok $test_count # \$/ preserved when set to bad value\n";
+++$test_count;
 
 # Now for the tricky bit--full record reading
 if ($^O eq 'VMS') {