Below is my code (don't worry there's a USUW at the top of the module)
I'm testing if an array ref is readonly, and if that is the case then I'm copying it into another array ref. The tests show that the array is not read-only, yet when it runs, it fails with that error. ( For those of you not familiar with me or Smart::Comments
--those ###
are Smart::Comments
.)
### readonly( $arg_ref ) : readonly( $arg_ref )
### readonly( @$arg_ref ) : readonly( @$arg_ref )
my @ro = map { readonly( $_ ) } @$arg_ref;
### @ro
if ( readonly $arg_ref ) {
$arg_ref = [ @$arg_ref ];
}
return map { my $val = shift @$arg_ref;
$_ => $val
} @_
;
This is the output I get:
### readonly( $arg_ref ) : 0
### readonly( @$arg_ref ) : 0
### @ro: [
### 0,
### 0,
### 0,
### 0,
### 0
### ]
But here's the error:
Modification of a read-only value attempted at ....pm line 247.
(247 is:
return map { my $val = shift @$arg_ref;
)
Does anybody have any familiarity with this issue? We're running Perl 5.8.7. Any idea on how to address it?