in reply to Re: Array, element inside limits
in thread Array, element inside limits

my %results = map { $_ => 1 if ( $low_watermark < $_ && $_ < $high_watermark ) } @all_numbers;

will get all of the matching numbers

Not if any of the numbers are duplicates because you are storing them in hash keys which will remove duplicates.

Why not just:

my @results = grep $low_watermark < $_ && $_ < $high_watermark, @all_n +umbers;

Replies are listed 'Best First'.
Re^3: Array, element inside limits
by Transient (Hermit) on Jun 15, 2009 at 17:11 UTC
    I assumed an instance of the number was sufficient and that duplicates could be ignored, but you're absolutely right. I think grep would be a better call.