Skip to content

Conversation

@aferreira
Copy link

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.

Regex objects (like qr/Foo/) are kind of special in Perl
because they have a REGEXP reftype but are blessed into the "Regexp"
package. That means qr/Foo/ is dumped as

    qr/Foo/

while regexes blessed to other packages than "Regexp"
should produce outputs like

    bless(qr/Foo/, "Regexp::Alt")
as they don't have much in common. And REGEXP are always refs
like other types as CODE, ARRAY, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant