Subject: | Can't modify values of hashref returned by Params::Validate::validate |
When receiving the results from Params::Validate::validate as a hashref
the values can't be modified. This appears to be due to the hashref
being created in the XS code. Reproduction attached.
./params_validate_hashref.pl
Modification of a read-only value attempted at
./params_validate_hashref.pl line 19.
Occurs under:
Linux:
Linux host 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:24:31 EDT 2006 x86_64
x86_64 x86_64 GNU/Linux
This is perl, v5.8.8 built for x86_64-linux
and Solaris:
SunOS host 5.8 Generic_117350-47 sun4u sparc SUNW,Netra-T12
This is perl, v5.8.8 built for sun4-solaris-64
Subject: | params_validate_hashref.pl |
#!/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Params::Validate qw(:types);
my $thing = new( -region => 'Aus' );
print Dumper($thing);
sub new {
my $self = Params::Validate::validate(
@_,
{ -region => { type => SCALAR }, }
);
$self->{'-region'} = lc $self->{'-region'};
return $self;
}