in reply to How to check if a scalar value is numeric or string?
XORing a number gives zero, so the function returns 1. XORing a string gives a string of nulls, still a non-empty string, so the function returns 0sub isnum ($) { $_[0] ^ $_[0] ? 0 : 1 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to check if a scalar value is numeric or string?
by ibravos (Initiate) on Mar 09, 2012 at 11:02 UTC |