如何打印v-string?

wag*_*hso 4 perl

如何打印v-string?

our $VERSION = v2.1;
print "$VERSION\n\n";
Run Code Online (Sandbox Code Playgroud)

打印表情. ??

yst*_*sth 9

你是什​​么意思打印V字符串?你想要什么输出?

你可以这样做:

printf "%vd", $VERSION;  # prints "2.1"
Run Code Online (Sandbox Code Playgroud)

或这个:

print version::->parse($VERSION)->stringify; # prints "v2.1"
Run Code Online (Sandbox Code Playgroud)

或这个:

print version::->parse($VERSION)->normal; # prints "v2.1.0"
Run Code Online (Sandbox Code Playgroud)

或这个:

print version::->parse($VERSION)->numify; # prints "2.001000"
Run Code Online (Sandbox Code Playgroud)

或者(最好的选择)你可以完全避免使用V字符串.