% perl -wle ' our $VERSION = "0.1_1"; $VERSION = eval $VERSION; if ($VERSION > 0.1 && $VERSION < 0.2) { print "ok"; } else { print "not ok"; } ' ok % perl -wle ' our $VERSION = "0.1_1"; $VERSION = eval { $VERSION }; if ($VERSION > 0.1 && $VERSION < 0.2) { print "ok"; } else { print "not ok"; } ' Argument "0.1_1" isn't numeric in numeric gt (>) at -e line 4. not ok %
eval STRING and eval BLOCK do different things. In this case the BLOCK form is effectively a no-op, so the string is numified using standard coercion during the comparison, and yields the value 0.1 (plus a warning). The string form means "take this string and interpret it as a program" - and Perl code lets us put underscores in numbers, even though the standard coercion rejects them, so it evaluates as the value 0.11.
I don't know about the version->parse variant, but I imagine that PAUSE would not find a version number to parse, so the module would not be indexed correctly.
In reply to Re^5: How Critical is Critic?
by hv
in thread How Critical is Critic?
by Bod
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |