|
|
Sponsor |
Regexp code feature: msg#00022lang.perl.modules.authors
What's the minimum version of Perl needed to reliably exploit the (?{ code }) feature in regexps? 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(?:000010101100010110(?{'2'})|1(?:000100111011101001000100100(? {'3'})|10110100(?:011011101111100011(?{'5'})|11110100011010(? {'4'}))))|1011010011001011100110101100(?{'1'}))"; It's used in this context, pulling the code values out via $^R: sub match_ip { my ($ip,$re) = @_; local $^R; use re 'eval'; unpack("B32", pack("C4", split(/\./, $ip))) =~ /$re/; return $^R; } Thanks much, 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/)
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Looking for Dominic Mitchell (author of Test::XML), Ovid |
|---|---|
| Next by Date: | Re: Regexp code feature, A. Pagaltzis |
| Previous by Thread: | Looking for Dominic Mitchell (author of Test::XML), Ovid |
| Next by Thread: | Re: Regexp code feature, A. Pagaltzis |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|