Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 ( #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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://778351]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-10-05 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (25 votes). Check out past polls.

    Notices?