sub compare_versions { my( $left, $right )= map lc, @_; for( $left, $right ) { s/(\d+)/pack("n",length$1).$1/ge; } return $left cmp $right; }