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(?:000010101100010110(?{'2'})|1(?:000100111011101001000100100(?{' 3'})|10110100(?:011011101111100011(?{'5'})|11110100011010(?{'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

Reply via email to