data-dump
data-dump copied to clipboard
Deal with blessed regexes
Regex objects (like qr/Foo/) are kind of special in Perl because they have a REGEXP reftype but are blessed into "Regexp" package. That means it is not desirable to dump qr/Foo/ into
bless(qr/Foo/, "Regexp")
which is redudant, but if the blessed package is other than "Regexp" it is necessary to resort to the "bless" expression, as in
bless(qr/Foo/, "Regexp::Alt")
Previous to this change, this was the output by Data::Dump for such cases:
perl -MData::Dump=pp -e 'pp(bless qr/Foo/, "Regexp::Alt")'
do {
my $a = bless(do{\(my $o = do{my $fix})}, "Regexp::Alt");
$$a = $a;
$a;
}
From this change on, the output becomes
perl -MData::Dump=pp -e 'pp(bless qr/Foo/, "Regexp::Alt")'
bless(qr/Foo/, "Regexp::Alt")
which evaluates correctly and that follows what Data::Dumper and Data::Dump::Streamer do.