Subject: | Hash loses regexp values |
Perl version: 5.8.8
The following code does not work as expected:
use Const::Fast;
const my %rx => ( foo => qr/foo/ );
See attached tryme.pl for some simple tests demonstrating the problem.
Subject: | tryme.pl |
#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use Const::Fast;
use Test::More;
use Data::Dumper;
{
const my $rx => { foo => qr/foo/ };
isa_ok $rx, 'HASH';
isa_ok $rx->{foo}, 'Regexp'; # passes
}
{
my %rx = ( foo => qr/foo/ );
isa_ok \%rx, 'HASH';
isa_ok $rx{foo}, 'Regexp'; # passes
}
{
const my %rx => ( foo => qr/foo/ );
isa_ok \%rx, 'HASH';
isa_ok $rx{foo}, 'Regexp' or diag( Dumper( \%rx ) ); # fails
}
done_testing();