I want to be able to generate a list of all possible matches for a pattern. This will be for phone numbers configured in a sip gateway where the numbers are added into the config as patterns, not individual numbers. I need to generate a list of all the numbers that a given gateway is configured to handle. The ranges are defined in a very simple notation, with "." being a wildcard (matches 0-9), and brackets holding a set and/or range of numbers.

For instance, given something like :

1115551234 111555124. 111555125[0,3-7]

I want to end up with a list like this :

1115551234 1115551240 1115551241 1115551242 1115551243 1115551244 1115551245 1115551246 1115551247 1115551248 1115551249 1115551250 1115551253 1115551254 1115551255 1115551256 1115551257

I've gotten to the point where i can get a nice array that has each place and either a digit or an array ref for those that have multiple matches. I just can't figure out a way to output all of the possible matches. I'm hoping there is a module that I can't find that can translate a pattern into a series of all possible matches. I've tried List::Maker, which comes so close it hurts, but still isn't quite what i need and I haven't been able to shoehorn it into what I'm seeking. I can think of a couple of ways to brute force my will onto this problem, I'm just trying to find a more elegant solution. I'm out of good ideas, and running low on bad ones, so I'm hoping someone has some guidance.


In reply to Getting a list of all possible pattern matches by inoci

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.