inoci has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting a list of all possible pattern matches
by AK108 (Friar) on Dec 13, 2007 at 20:16 UTC | |
by inoci (Scribe) on Dec 13, 2007 at 20:48 UTC | |
|
Re: Getting a list of all possible pattern matches
by moritz (Cardinal) on Dec 13, 2007 at 19:00 UTC | |
by inoci (Scribe) on Dec 13, 2007 at 19:33 UTC | |
|
Re: Getting a list of all possible pattern matches
by Cristoforo (Curate) on Dec 14, 2007 at 00:34 UTC |