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

标签 perl version versioning

我有这个衬垫:

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/

相关文章:

ios - Xcode出于未知原因给出版本兼容性警告

java - 升级已发布的 Android App 的 minSdk

visual-studio-2012 - 将 VS2013 SSIS 包部署到 SQL Server 2012 并在 VS2012 中编辑

open-source - 礼仪 : Version bump my fork of opensource project?

linux - 如何使用 sed 或 Perl 删除多行 block 中的部分行?

java - Hadoop上出现UnsupportedClassVersionError,版本没有明显变化

python - 依次运行多个命令行 linux python

c# - 如何更改 exe 文件的文件和产品版本

regex - Perl:无法从文件中获取正确的匹配项

javascript - 无法使用 AJAX 调用在后端服务器上保存上传视频的 blob URL