Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: iterating through array and saving matches to new array

by pwagyi (Monk)
on Apr 16, 2018 at 07:15 UTC ( [id://1212966] : note . print w/replies, xml ) Need Help??


in reply to iterating through array and saving matches to new array

As other monks had pointed out, use lexical scope (my over our). and grep is definitely suitable here. I'm not exactly sure why you need even grep/filtering if you want to find numbers between 850 and 1000? You could as well use.

my $lower_bound = 850; my $upper_bound = 1000; my @newa = ($lower_bound+1 .. $upper_bound);