Perl compare version numbers 5.1 < 5.10
问题 I am having difficulties in comparing 2 versions. If we have 5.1 and 5.10 then 5.1 should be smaller than 5.10. I know that in decimal it should read 5.01 and 5.10. But is there a way to compare it using 5.1 and 5.10? perl -e 'use warnings; use version; if (version->parse("5.1") < version->parse("5.10")) { print "ok"; }' 回答1: The version module documentation shows how to do this: print version->declare('5.1')->numify; # 5.00100 print version->declare('5.10')->numify; # 5.01000 回答2: Use the