Dont know if its faster, cause I didnt benchmark, but I like hashes a little better for this type of work, and for me its a little cleaner to write the same thing like so
%data = map { $_ => 1 } @F;
sub range{
my(@ret);
for ($_[0] .. $_[1]) {
push(@ret, $_) if ($data{$_});
}
return @ret;
}
Which produces the same output as your code... Critique any one?
Edit: I guess it would make more sense to initialize the data into a hash, as opposed to the array and then using map.
Also thinking about it I would probably pass a third arg being the ref to the data hash, I wanted to work on.
Edit_2: Doh that shoulda been defined in the loop :P.. o well.
/* And the Creator, against his better judgement, wrote man.c */