use 5.010; use Scalar::Util qw(looks_like_number); sub is_int (_) { my $i = shift; looks_like_number($i) and int($i)==$i; } say for grep { is_int } qw( -6 5.2 5.0 3e4 0Hello );
Note that this classes 5.0 as an integer, which is correct from a maths point of view, but not necessarily from a comp sci one.
In reply to Re: Data::Types or grok_number
by tobyink
in thread Data::Types or grok_number
by tqisjim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |