Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: regex to an array , is there a better way to do this

by ramlight (Friar)
on Jul 08, 2009 at 17:11 UTC ( [id://778351] : note . print w/replies, xml ) Need Help??


in reply to regex to an array , is there a better way to do this

You can even cut it down to
chomp(my $number = <STDIN>); my @array; foreach (split(",", $number)) { push @array, /(\d+)\.\.(\d+)/ ? $1..$2 : $_; } print "@array\n";
I don't think it is quite as clear what is going on at this level of compression.