#!/usr/bin/perl use strict; use warnings; use Scalar::Util qw(looks_like_number); my @list = qw(1 "1" "1o"); foreach my $foo (@list) { if( looks_like_number( $foo ) ) { print "number\n"; }else{ print "string\n"; } }
Just use looks_like_number from Scalar::Util
In reply to Re: How can I test for the representation of an integer?
by Anonymous Monk
in thread How can I test for the representation of an integer?
by sm@sh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |