Subject: | Fatal error if $_ is set to a Readonly value when "local $_;" is executed |
Script dies with error
Modification of a read-only value attempted at ...
if $_ is set to a Readonly value when "local $_;" is executed.
Example:
Readonly::Array my @UPPERCASE => 'A' .. 'C';
localize_dollar( $_ ) for @UPPERCASE;
sub localize_dollar {
local $_;
}
Readonly-1.03
Test-Simple-0.62
This is perl, v5.8.4 built for i686-linux-thread-multi
Linux coitlx05 2.4.21-32.0.1.ELhugemem #1 SMP Tue May 17 17:43:22 EDT
2005 i686
Subject: | readonly.t |
#!/ms/dist/perl5/bin/perl5.8
#
# Test script to reproduce error:
# Modification of a read-only value attempted at ...
#
# $_ is set to a Readonly value when "local $_;" is executed.
#
use strict;
use warnings;
use Test::More qw( no_plan );
use Readonly;
my @lowercase = 'a' .. 'c';
Readonly::Array my @UPPERCASE => 'A' .. 'C';
Readonly my @MIXEDCASE => qw( X y Z );
localize_dollar( $_ ) for ( @lowercase, @UPPERCASE, @MIXEDCASE );
sub localize_dollar {
my $value = shift;
my $t = "test case '$value'";
diag( "Running $t" );
local $_;
ok( 1, "Ran $t: OK" );
}