Subject: | looks_like_number ... no? |
MongoDB has some type checking that I'm unaccustomed to in Perl settings
and I find counter-intuitive and arguably even wrong ... Although your
opinion may differ from mine ...
Consider this code:
if( my $b = $cgi->param("b") ) {
if( my $es = eval{ UnixDate(ParseDate($b), '%s') } ) {
$search->{_id}{'$gte'} = $es;
}
}
This was not working right at all until I had the idea that perhaps the
type checking was happening on in C where you can more easily check
things perl people sometimes cannot (ie, NV vs PV).
Up at the high level, the best I can do is
Scalar::util::looks_like_number($epoch_seconds_string); and it surely does.
So I had the genius idea to do this:
$search->{_id}{'$gte'} = 0 + $es;
But I don't think I should have to, not in Perl anyway. In Python,
sure, but not in Perl.
-Paul
--
If riding in an airplane is flying, then riding in a boat is swimming.
116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.