为什么版本不可打印?
Why version is not printable?
我有这个衬垫:
perl -Mversion -e 'our $VERSION = v1.02; print $VERSION'
输出为(不可见,有两个字符:1、2):
为什么模块版本不可打印?我希望看到 v1.02
我找到了这个DOC
print v9786; # prints SMILEY, "\x{263a}"
print v102.111.111; # prints "foo"
print 102.111.111; # same
回答我的问题:
尽管 v1.02
是 v-string
内部不是字符串。当我们想要打印它时,我们应该做额外的步骤。例如,按照上面的建议使用模块 version
。
UPD
我找到了下一个解决方案 (DOC):
printf "%vd", $VERSION; # prints "1.2"
UPD
而this应该读作:
There are two ways to enter v-strings: a bare number with two or more decimal points, or a bare number with one or more decimal points and a leading 'v' character (also bare). For example:
$vs1 = 1.2.3; # encoded as
$vs2 = v1.2; # encoded as
我有这个衬垫:
perl -Mversion -e 'our $VERSION = v1.02; print $VERSION'
输出为(不可见,有两个字符:1、2):
为什么模块版本不可打印?我希望看到 v1.02
我找到了这个DOC
print v9786; # prints SMILEY, "\x{263a}"
print v102.111.111; # prints "foo"
print 102.111.111; # same
回答我的问题:
尽管 v1.02
是 v-string
内部不是字符串。当我们想要打印它时,我们应该做额外的步骤。例如,按照上面的建议使用模块 version
。
UPD
我找到了下一个解决方案 (DOC):
printf "%vd", $VERSION; # prints "1.2"
UPD
而this应该读作:
There are two ways to enter v-strings: a bare number with two or more decimal points, or a bare number with one or more decimal points and a leading 'v' character (also bare). For example:
$vs1 = 1.2.3; # encoded as
$vs2 = v1.2; # encoded as