On Wed, 26 Feb 2003 19:47:35 -0500, Casey West wrote:

> Here's a nice trick.  Use the int() function.  It's documented in
> perlfunc, a short to the documentation is 'perldoc -f int'.
> 
> When passed a string, int() will return 0.  When passed a number, it
> will return the integer version of that number.  Armed with this
> knowledge, it's fair to assume that when passed an integer, the
> following expression will be true:
> 
>   $data == int( $data );

Sorry, but that's wrong.
Have a look to this one liner:
perl -e '$x = "123kg"; print "$x is ", ($x == int($x)) ? "numeric" : "a string"'

int() interpretes its argument in numeric context what will be with most
strings 0 (if the string starts with a non-number). But if it starts with
something number-like it's whole a different story.


Cheerio,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to