Hi all,

On Tue, 25 Feb 2014 17:07:00 -0800
Jim Gibson <jimsgib...@gmail.com> wrote:

> 
> On Feb 25, 2014, at 2:30 PM, Bill McCormick wrote:
> 
> > What would be the perl'ish way using map or some other sugar to check if a
> > list of values meet some criteria? Instead of doing something like
> > 
> > my @issues = qq(123,456,a45);
> > my $max = 999;
> > 
> > for (@issues) {
> >  die if $_ < 0 or $_ > $max;
> > }
> > 
> > I want to check if each list item is numeric and > 0 but less than $max.
> > 
> > Cheers!
> 
> grep is the Perl function for testing a list of values against some criteria.
> 
> perldoc -f grep
> 
> 'grep BLOCK LIST' will return all of the items in LIST that result in a true
> value when BLOCK is evaluated. In scalar context, grep returns the number of
> items that evaluated to true, so you can either save all of the true-ish
> items or just get a count.
> 

In this case, I think the functions all/any/notall/none from List::MoreUtils
will be better:

https://metacpan.org/pod/List::MoreUtils

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

Wikipedia has a page about everything including the
http://en.wikipedia.org/wiki/Kitchen_sink .

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to