Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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.

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?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found