develooper Front page | perl.perl5.porters | Postings from August 2001

Re: [PATCH 2 of 3] $] is deprecated - EXTERMINATE, EXTERMINATE, EXTERMINATE

Thread Previous | Thread Next
From:
Abigail
Date:
August 23, 2001 12:39
Subject:
Re: [PATCH 2 of 3] $] is deprecated - EXTERMINATE, EXTERMINATE, EXTERMINATE
Message ID:
20010823193838.11745.qmail@foad.org
On Thu, Aug 23, 2001 at 12:31:30PM -0400, John Peacock wrote:
> Rafael Garcia-Suarez wrote:
> > 
> > And this seems a little bit too DWIMmy: I expect "5.6.1" to be
> > equivalent to v53.46.54.46.49. At least on ASCII machines.
> 
> Why would you imagine it would do that?

Eh, because it currently does, and that behaviour is documented?

    $ perl -wle 'print "Yes" if "5.6.1" eq v53.46.54.46.49'          
    Yes
    $

That's for 5.6.1. From perldata.pod:

A literal of the form C<v1.20.300.4000> is parsed as a string composed
of characters with the specified ordinals.  This provides an alternative,
more readable way to construct strings, rather than use the somewhat less
readable interpolation form C<"\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, C<cmp>, C<gt>, C<lt> etc.   
If there are two or more dots in the literal, the leading C<v> may be
omitted.

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




Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About