How can I create a qr// in Perl 5.12 from C?

Posted by kristina on Stack Overflow See other posts from Stack Overflow or by kristina
Published on 2010-04-21T18:16:46Z Indexed on 2010/04/21 18:43 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

This has been working for me in 5.8 and 5.10, but in 5.12 my code creates this weird non-qr object:

# running "print Dumper($regex)"
$VAR1 = bless( do{\(my $o = '')}, 'Regexp' );

Whereas printing a qr// not created by my code looks like this:

# running "print Dumper(qr/foo/i)"
$VAR1 = qr/(?i-xsm:foo)/;

My code is basically:

REGEXP *rx = re_compile(pattern, flags);
SV *regex = sv_2mortal(newSVpv("",0));

sv_magic(regex, (SV*)rx, PERL_MAGIC_qr, 0, 0);

stash = gv_stashpv("Regexp", 0);
sv_bless(newRV((SV*)regex), stash);

Anyone know how to correctly create a regex from a string in 5.12?

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex