in reply to Re^3: Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)
in thread Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)

The input will be constrained and only allow ".." "," and digits.
And the digits will only be positive whole numbers.
I have not worked out the regex for this,
but yours is a starting point.

And thank you for the explaination of your solution!
  • Comment on Re^4: Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)

Replies are listed 'Best First'.
Re^5: Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)
by GrandFather (Saint) on Oct 10, 2005 at 03:08 UTC

    This may be of interest:

    my @ranges = ('2..5,10..15', '2..5', 'die', '-2..5,10..15'); my $match = qr /^\d+\.{2}\d+(,\d+\.{2}\d+)*/; print ((m|$match| ? "ok: " : "Rejected: ") . "$_\n") for (@range +s);

    No need to throw out the eval through pathalogical fear when validating the data in a simple fashion removes the danger of an exploit.


    Perl is Huffman encoded by design.