in reply to Re: screen out an untained array from a special array
in thread screen out an untained array from a special array
I don't think the OP has just an array of numbers. I think it is a series of minimums and maximums separated by a colon.
my @array = qw/0:2 4:6 8:12/; my %hash; foreach my $ele (@array) { my @temp = split /:/, $ele; $hash{$_}++ foreach $temp[0]..$temp[1]; }
I'll let the OP figure out how to deal with max:min pairs. The code I provided will only work for min:max pairs.
Updated with snippet. (I hope I did not do too much work for the OP.)
And you didn't even know bears could type.
|
|---|