On 25/02/2014 23:46, Bill McCormick wrote:
On 2/25/2014 4:36 PM, Bill McCormick wrote:
On 2/25/2014 4: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;
}
Revision:
for(@issues) {
print "issue=[$_]\n";
die "$_ not a number\n" if $_ ne $_+0;
die "$_ not in range\n" if $_ < 0 || $_ > $max;
}
Thanks everyone for the speedy replies. I was looking to just use raw
perl for this. This is for an svn PRE_COMMIT hook, where issues is a
list of bz issues.
Hi Bill
As far as I can tell Ron's solution is the better one. The Scalar::Util
module has been part of core perl since version 7.3 of Perl 5, which was
released in March of 2002. Unless your version is over twelve years old
you can consider `looks_like_number` to be part of "raw Perl".
Rob
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/