in reply to Re^4: loop iterator in a string
in thread loop iterator in a string
I think rejecting any $str containing anything which isn't a cipher, comma or dot prior to eval $str should be good enough
Not quite, since it would also accept ",....," and other things like that (one of the things I meant with "other subtle bugs"). Personally I would suggest both a regex like /\A(\d+(?:\.\.\d+)?)(?:,(?1))*\z/ and checking eval for errors. And at that level, the complexity is high enough that something like* tybalt89's solution is probably better.
* Update: By which I mean, something like tybalt89's solution with some added error checking ;-)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: loop iterator in a string
by LanX (Saint) on Sep 28, 2021 at 10:53 UTC | |
by haukex (Archbishop) on Sep 28, 2021 at 11:07 UTC | |
by LanX (Saint) on Sep 28, 2021 at 11:11 UTC | |
by LanX (Saint) on Sep 28, 2021 at 15:42 UTC |
In Section
Seekers of Perl Wisdom