in reply to How to check if a scalar value is numeric or string?
try extending on this principle, here is a snippet:
my $x=111; my $y="111"; print "\$x is a number\n" if !($x & ~$x); print "\$y is a string\n" if ($y & ~$y);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to check if a scalar value is numeric or string?
by ikegami (Patriarch) on Aug 27, 2009 at 16:18 UTC | |
by Anonymous Monk on Feb 07, 2017 at 19:42 UTC | |
by voidzero (Initiate) on Jul 18, 2023 at 08:01 UTC | |
by hippo (Archbishop) on Jul 18, 2023 at 08:59 UTC | |
by eyepopslikeamosquito (Archbishop) on Jul 18, 2023 at 09:45 UTC | |
by haj (Vicar) on Jul 18, 2023 at 08:57 UTC | |
Re^2: How to check if a scalar value is numeric or string?
by bgupta (Novice) on Aug 27, 2009 at 16:07 UTC | |
by ig (Vicar) on Aug 28, 2009 at 00:55 UTC |