Comment has asked for the wisdom of the Perl Monks concerning the following question:
Thanks in advance for your assistance!
I would like to convert a string containing number ranges to an array. Here is an example string:
$string = "1,5,7..10,15,17..19,22";I would like to convert $string to an @array that would have the following keys and values:
(key -> value)Normally, I would go with the split() function and separate on the commas, but I cannot figure out how to get the ranges to fill in the array properly.
Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting String Containing Ranges to Array
by kennethk (Abbot) on Sep 23, 2010 at 20:12 UTC | |
|
Re: Converting String Containing Ranges to Array
by Corion (Patriarch) on Sep 23, 2010 at 20:15 UTC | |
|
Re: Converting String Containing Ranges to Array
by BrowserUk (Patriarch) on Sep 23, 2010 at 20:24 UTC | |
|
Re: Converting String Containing Ranges to Array
by toolic (Bishop) on Sep 23, 2010 at 20:34 UTC | |
|
Re: Converting String Containing Ranges to Array
by Anonymous Monk on Sep 23, 2010 at 21:26 UTC |