$_ read-only issue on "21". Not new, always has been
[email protected] ("H.Merijn Brand" via perl5-porters) Thu, 16 Apr 2026 09:30:04 +0200
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <20260416093004.1f247598@pc09> |
I am really stunned that I have never hit this before, as it exists for
all versions of perl, but for some with a twist ...
--8<--- test.pl
#!/usr/bin/perl
use strict;
use warnings;
our $VERSION = "1.00";
sub foo {
my $x = shift;
my $n = 0;
my $f = $0;
open my $fh, "<", $f or return;
while (<$fh>) {
$n++;
}
close $fh;
} # foo
foo ($_) for "00".."13","21",30..50;
-->8---
🐧 perl test.pl
Modification of a read-only value attempted at test.pl line 13.
Adding `local $_;` before the `while (<$fh>) {` is a workaround
but somehow my brain always thought that $_ would have been localized
or lexicalized inside the while. Obviously not
Weird is that - at least on my side - this read-only fail *ONLY*
happens on "21" If I leave out "21", all PASSs on ALL perl releases
Now check when that was introduced ...
🐧 perl-all test.pl
Running perl-all test.pl
On 621 versions of perl
ranging from perl5.6.0 to tperl5.43.7
=== base/perl5.6.0 5.006 x86_64-linux
Modification of a read-only value attempted at test.pl line 13.
Exit status: 65280
=== base/perl5.6.1 5.006001 x86_64-linux-perlio
Modification of a read-only value attempted at test.pl line 13.
Exit status: 65280
=== base/tperl5.6.1 5.006001 x86_64-linux-thread-multi-ld-perlio
Modification of a read-only value attempted at test.pl line 13.
Exit status: 65280
:
:
=== base/tperl5.28.1 5.028001 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
=== base/cperl5.28.2 5.028002 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted PV("21"\0) at sv.c:5284 at test.pl line 13.
Exit status: 65280
:
:
=== base/tperl5.28.3 5.028003 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
=== base/cperl5.28 5.028002 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted PV("21"\0) at sv.c:5284 at test.pl line 13.
Exit status: 65280
:
:
=== base/tperl5.29.0 5.029000 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
cperl5.29.1: /lib64/libffi.so.7: version `LIBFFI_BASE_7.0' not found (required by cperl5.29.1)
=== base/cperl5.29.1
cperl5.29.1: /lib64/libffi.so.7: version `LIBFFI_BASE_7.0' not found (required by cperl5.29.1)
Exit status: 256
:
:
=== base/tperl5.29.10 5.029010 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
cperl5.29: /lib64/libffi.so.7: version `LIBFFI_BASE_7.0' not found (required by cperl5.29)
=== base/cperl5.29
cperl5.29: /lib64/libffi.so.7: version `LIBFFI_BASE_7.0' not found (required by cperl5.29)
Exit status: 256
=== base/tperl5.43 5.043007 x86_64-linux-thread-multi-ld
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
=== /usr/bin/perl 5.042000 x86_64-linux-thread-multi
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
=== /pro/bin/perl 5.042002 x86_64-linux-thread-multi-quadmath
Modification of a read-only value attempted at test.pl line 13.
Exit status: 6400
--
H.Merijn Brand https://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.37 porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEGolmczWuFi3lJEbAA6FHoT5dwJgFAmngj/wACgkQA6FHoT5d wJgigQf+PRy85GqWRp36uzQ7tiIj1NX+2qPBVe06KmIt74mhIsPOc+fAEJoXb4eH jPBNBNW6wEWA2DsxmTE8wUBa+y1EN0LmYN21Hez0u8W7YXLTzwQdRehWgxIp0jSS ubU5QoGRiguFD+Ewq3Vs/qNBcpTMR5ly+kBk5VVEkmIHxI4tZRT5LIoC+TJJek3x Tz8r1cM6ixhh28i23EQh83WRyUgSBYxMtT1pWOUe+879+u/LG4ZITCb+rU69heTm ZzL+8/qOklo1XZFTBpKjPAT+Obu7IKL5v9ocjc1dm44vkAcvf0NkOC0DZE6wCqKR y4BS2qu43fp6I5U4+XGguV2dMo2yBw== =gAO8 -----END PGP SIGNATURE-----