develooper Front page | perl.perl5.porters | Postings from August 2012

Anyone know how to compile a regex in XS/C in Perl 5.8.5?

Thread Next
From:
demerphq
Date:
August 28, 2012 08:48
Subject:
Anyone know how to compile a regex in XS/C in Perl 5.8.5?
Message ID:
CANgJU+UeNJ+XSKuMoNpsAgDDTzUmsQE9=HG-TOu=MxnQLGLM2g@mail.gmail.com
I was wondering if anyone knew of any existing code that knows how to
compile a regular expression properly in perl 5.8.5

I cribbed this together but it Isn't working.

            PMOP pm; /* grr */
            pm.op_pmdynflags= SvUTF8(pat) ? PMdf_CMP_UTF8 : 0;
            pm.op_pmflags= flags;
            SV *sv= newSVpv("",0);
            re= CALLREGCOMP(aTHX_ (char *)pat,(char *)(pat+len),&pm);
            sv_magic(sv, (SV*)re, PERL_MAGIC_qr, 0, 0);
            ret= newRV_noinc(sv);

Basically I want to do the same thing that a qr// operator would do,
but bypassing the normal op for it.

I will note that in more modern perls it is easy to do, but in older
ones I'm a little foxed.

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About