Peter Rabbitson wrote:
> I stumbled upon a script with the following assignment:
> ... = v(numeric value);
> 
> I tried to see how it works and the following:
> my $a = v65;
> print $a;
> 
> produces ascii 65 (capital A)
> 
> Where can I read more about these assignment modifiers?


perldoc perldata
[snip]
       Version Strings

       Note: Version Strings (v-strings) have been deprecated.  They will not
       be available after Perl 5.8.  The marginal benefits of v-strings were
       greatly outweighed by the potential for Surprise and Confusion.

       A literal of the form "v1.20.300.4000" is parsed as a string composed
       of characters with the specified ordinals.  This form, known as
       v-strings, provides an alternative, more readable way to construct
       strings, rather than use the somewhat less readable interpolation form
       "\x{1}\x{14}\x{12c}\x{fa0}".  This is useful for representing Unicode
       strings, and for comparing version "numbers" using the string
       comparison operators, "cmp", "gt", "lt" etc.  If there are two or more
       dots in the literal, the leading "v" may be omitted.

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

       Such literals are accepted by both "require" and "use" for doing a
       version check.  The $^V special variable also contains the running Perl
       interpreter's version in this form.  See "$^V" in perlvar.  Note that
       using the v-strings for IPv4 addresses is not portable unless you also
       use the inet_aton()/inet_ntoa() routines of the Socket package.

       Note that since Perl 5.8.1 the single-number v-strings (like "v65") are
       not v-strings before the "=>" operator (which is usually used to
       separate a hash key from a hash value), instead they are interpreted as
       literal strings ('v65').  They were v-strings from Perl 5.6.0 to Perl
       5.8.0, but that caused more confusion and breakage than good.
       Multi-number v-strings like "v65.66" and 65.66.67 continue to be
       v-strings always.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to