Re: Regexp code feature
On Jul 21, 2005, at 3:17 PM, A. Pagaltzis wrote: * Chris Dolan [EMAIL PROTECTED] [2005-07-21 22:05]: What's the minimum version of Perl needed to reliably exploit the (?{ code }) feature in regexps? You can check at http://search.cpan.org/dist/perl/. The first version where pelre documents this feature is 5.005. Though as far as “reliably” is concerned: it has never lost its “experimental” status. Even if I doubt that it would be removed from Perl5 at this point. Thanks, Aristotle. After checking that URL, I've confirmed that 5.005 probably *could* work, but I've successfully tested my module on 5.6.0 and called that good enough (since I use our, etc). I've uploaded Net::IP::Match::Regexp to CPAN. Yes, I see your point about the experimental status. Well, it's the only way I could think of to implement varying return values via the regexp. I'm using only the most basic aspect of the (?{code}) feature, so I'm safe unless someone takes $^R away from me. :-) Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Re: Regexp code feature
* Chris Dolan [EMAIL PROTECTED] [2005-07-21 23:30]: Yes, I see your point about the experimental status. Well, it's the only way I could think of to implement varying return values via the regexp. I'm using only the most basic aspect of the (?{code}) feature, so I'm safe unless someone takes $^R away from me. :-) Well, not to worry. I rely on the thing a lot, myself. I’m just nitpicking about your use of “reliably.” ;-) Regards, -- #Aristotle *AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
Re: Regexp code feature
Chris Dolan wrote: I'm working on a module that I call Net::IP::Match::Regexp which builds and runs regexps that contain simple code blocks. It works great under 5.8.1 on my Mac, but I haven't tested older Perl versions yet. My code turns these IP ranges (randomly generated) 109.27.190.54/28= 1 109.61.26.198/24= 2 180.203.154.195/28 = 3 5.98.198.68/19 = 4 68.238.145.35/29= 5 into regexps look like this: my $re = ^(?:0(?:10101100010110(?{'2'})|1(?:000100111011101001000100100(?{' 3'})|10110100(?:01101110100011(?{'5'})|0100011010(?{'4'}|10 11010011001011100110101100(?{'1'})); I may be wrong, but this looks similar to what Regexp::Assemble does, or that you could use it to ease your task. http://search.cpan.org/dist/Regexp-Assemble/ Sébastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO