我有这个衬垫:
perl -Mversion -e '我们的 $VERSION = v1.02;打印 $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 \1\2\3
$vs2 = v1.2; # encoded as \1\2
关于perl - 为什么版本不可打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44670559/