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 poolpi (Hermit)
on Jul 09, 2009 at 11:10 UTC ( #778540=note: print w/ replies, xml ) Need Help??


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

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Set::IntSpan; chomp( my $numbers = <STDIN> ); # $numbers = '1,2,4,6..18,47,49,55..65,90'; my $run_list = [ eval $numbers ]; my $set; eval { $set = new Set::IntSpan $run_list }; $@ and print "$@: Try again\n"; my @elem = elements $set; print Dumper \@elem; #Output: # $VAR1 = [ # 1, 2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, # 47, 49, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 90 # ];


hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb


Comment on Re: regex to an array , is there a better way to do this
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-07-12 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls