Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found