Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: 1 vs "1"

by Caillte (Friar)
on Sep 12, 2001 at 20:50 UTC ( #111953=note: print w/replies, xml ) Need Help??


in reply to 1 vs "1"

A limited method, but one that could be built on is to use +0. Using an eval like the example below will return 0 if fed a string containing no numeric characters or the number 0 so, something like this could be a start:

foreach my $var ('0', '-112.04', 'qwerty') { $var2 = eval '$var+0'; if($var eq '0' or $var2) { print "Is an number\n"; } else { print "May not be an number\n"; } }

$japh->{'Caillte'} = $me;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://111953]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-08-10 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?