kiat has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm curious why the statement below prints the characters 'foo':
print v102.111.111;
Please enlighten me and thanks in anticipation :)

kiat

Replies are listed 'Best First'.
Re: v-string
by BrentDax (Hermit) on Mar 03, 2002 at 06:32 UTC
    v1.2.3 is equivalent to chr(1).chr(2).chr(3) by design. By doing this, v1.11 gt v1.2 is true. If you want to print out a vstring, use (s)printf's %v specifier. However, note that this will be changing in Perl 5.8--vstrings will become objects (I think the class will be UNIVERSAL::version).

    =cut
    --Brent Dax
    There is no sig.

Re: v-string
by particle (Vicar) on Mar 03, 2002 at 06:24 UTC
Re: v-string
by kiat (Vicar) on Mar 05, 2002 at 13:24 UTC
    Thanks for responding!

    The example comes from "Programming Perl 3rd Edition" (Larry Wall et al), p. 67.

Re: v-string
by thor (Priest) on Mar 04, 2002 at 05:25 UTC
    A better question is: "how did you come up with your example"? It seems very coincidental that your example gives "foo"...;)