looks_like_number()
DBI->looks_like_number(@array)This method is used for testing a given array to determine whether each element seems to be a number or not. It returns 1 for each element in an array that appears to be a number; 0 for those that do not. It returns undefined if the element is empty or undefined. Here is an example:
...
my $sql_stmnt = "SELECT book_id, title, author, isbn
FROM books LIMIT 1";
my $sth = $dbh->prepare($sql_stmnt);
$sth->execute();
my (@book) = $sth->fetchrow_array();
my @num_assessment = DBI->looks_like_number(@book);
my $cnt = 0;
foreach (@num_assessment) {
if($_) { print "Array Element $cnt looks like a number.\n" };
++$cnt;
}The results of this code will show that elements 1 and 4 appear to be numbers.