Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why version is not printable?

I have this one liner:

perl -Mversion -e 'our $VERSION = v1.02; print $VERSION'

The output is (It is not visible, there is two characters: 1, 2):

enter image description here

Why module version is not printable? I expect to see v1.02

like image 426
Eugen Konkov Avatar asked Nov 21 '25 05:11

Eugen Konkov


1 Answers

I have found this DOC

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

Answering to my question:
Despite on that v1.02 is v-string that is not string internally. And when we want to print it we should do extra steps. For example, use module version as suggested above.

UPD
I found next solution (DOC):

printf "%vd", $VERSION;  # prints "1.2"

UPD

And this should be read:

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
like image 86
Eugen Konkov Avatar answered Nov 22 '25 18:11

Eugen Konkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!