in reply to Re^2: Specifying a range through a variable
in thread Specifying a range through a variable

Use eval, if you must.

my $range = '1..10'; for my $x ( eval $range ) { print "$x\n"; }

Beware, however, that input validation is very important here. The string you pass into eval can be any Perl code, and it will do whatever that code does.

Replies are listed 'Best First'.
Re^4: Specifying a range through a variable
by Zubinix (Acolyte) on Sep 19, 2008 at 02:37 UTC
    Also something like this work to:
    my $a = 1; my $b = 10; my @range = $a .. $b; for my $x (@range) { print "$x\n"; }
    So I could parse the start and end of range into variables. Cool. Thanks.