Why is the version not printable?

I have one liner:

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

Output (not visible, there are two symbols: 1, 2):

enter image description here

Why is the module version not available for printing? I expect to seev1.02

+3


source to share


1 answer


I found this DOC

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

      

Answering my question:
Although v1.02

there is v-string

, which is not internal. And when we want to print it, we have to take additional steps. For example, use the module version

as suggested above.

UPD
I found the following 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

      

+6


source







All Articles