perl -e 'print "yikes\n" if int("1upmanship")' perl -e 'print "Zero is a number.\n" if int("0")'
prints yikes! but not the "Zero..." line. int() doens't test a number it truncates it to integer form. And since the number 0 is false the second line doesn't work. Treating a string that starts with numeral as a number causes perl to whack off the text and use the number. OUCH!
--
$you = new YOU;
honk() if $you->love(perl)
In reply to RE: markjugg-- using int to test numberness
by extremely
in thread Number?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |