gpt4 book ai didi

perl - 为什么版本不可打印?

转载 作者:行者123 更新时间:2023-12-01 10:29:08 25 4
gpt4 key购买 nike

我有这个衬垫:

perl -Mversion -e '我们的 $VERSION = v1.02;打印 $VERSION'

输出为(不可见,有两个字符:1、2):

enter image description here

为什么模块版本不可打印?我希望看到 v1.02

最佳答案

我找到了这个 DOC

print v9786;              # prints SMILEY, "\x{263a}"
print v102.111.111; # prints "foo"
print 102.111.111; # same

回答我的问题:
尽管 v1.02v-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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com