Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://778540]
help
Chatterbox?
[usemodperl]: someone has yet to make that future famous free http to https proxy written in perl and supported by ads, paypal, patreon, etc to make millions of dollars a minute!
[Veltro]: Why would this be fresh, I recon this is stuff that happens all the time (not Perl per se)
[Corion]: usemodperl: I'm sure you could even code that on the command line.
[usemodperl]: definitely

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2018-06-24 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?