in reply to finding multiples of two values
is evaluated before the return.$_[0] =~ /^\s*\+\-?\d+\s*$/
In a scalar context it returns the number of matches.
Therefore as the regex is anchored start and end, if the supplied string is an integer the regex returns 1 otherwise 0, which are evaluated as true and false. Thus the above routine could be employed as follows
You need to check if the modulus of the numbers is zero, perhaps a has_remainder function?if (is_integer_string($input){ do_integer_function($input); } else{ die "You must supply an integer\n"; }
Hope that clarifies.
|
|---|