in reply to use string as a piece of code

eval.

my $str = '1..3,10..14'; do_something($_) for eval $str;

Just be very sure that you trust whoever created the file you're reading from. What happens if it contains "system qw{rm -rf /}" (or the equivalent on your OS)?

update: Added code

Replies are listed 'Best First'.
Re^2: use string as a piece of code
by daverave (Scribe) on Jul 30, 2010 at 16:49 UTC
    Thanks!

    A followup: my ranges are quite large (~500k numbers, usually in one or two blocks only, i.e. something like 1..20000,700000..1000000).

    What is the efficient way to simply print them out to a file?

    Maybe  for $i (1..20000,700000..1000000) {print "$i "}? I'm not sure if an array is actually created here... if it is, maybe it's not a good idea.