|Perl Monk, Perl Meditation|
Combine range of numbers.by the_0ne (Pilgrim)
|on Jan 31, 2004 at 04:27 UTC||Need Help??|
the_0ne has asked for the
wisdom of the Perl Monks concerning the following question:
Hi Monks, I know my title is vague, but I thought I'd let the actual content speak for itself. Here's what I want to do. I want to take this...
and turn it into this
I do have code and it works, however it just doesn't look perlish to me. I've always thought of regexes as basicly "can do anything with text". I tried a few and they just failed miserably. Here is my code...
It just looks so un-perlish. It does work and so far I haven't found a combination that breaks it. (The reason I say that is because this is part of a larger script that formats the input from the user like that. So, the numbers will always be in order and comma-delimited before it gets to that chunk of code.) However, it just looks like way too much code to do something so trivial. I won't ask if there is a better way, because Perl wouldn't be Perl if there wasn't. I'd just like to see what other Monks would do with this problem.