develooper Front page | perl.perl5.porters | Postings from February 2000

Re: v5.5.650, aka five point six beta1, is out

From:
Larry Wall
Date:
February 9, 2000 10:20
Subject:
Re: v5.5.650, aka five point six beta1, is out
Message ID:
200002091819.KAA20502@kiev.wall.org
Mark Mielke writes:
: On Tue, Feb 08, 2000 at 03:05:38PM -0800, "Gurusamy Sarathy" wrote:
: >   + support sprintf("v%v", v1.2.3) (works on any string argument, in
: >     fact)
: 
: Something interesting... (although I'm sure I'm not the first to notice...)
: 
:    use Socket;
:    my $addr = inet_aton("127.0.0.1");
:    printf "%v\n", $addr;   # Prints 127.0.0.1
: 
: I thought that was kind of cool... :-)

The really, really cool thing is that it also works with utf8, even when
you have bytes above 127.  Watch this:

    use Socket;
    my $addr1 = inet_aton("205.178.11.135");
    my $addr2 = v205.178.11.135;
     
    printf "%v\n", $addr1;	# prints 205.178.11.135
    printf "%v\n", $addr2;	# prints 205.178.11.135

    print length($addr1),"\n";	# prints 4
    print length($addr2),"\n";	# prints 4
     
    use byte;			# old perl semantics
    print length($addr1),"\n";	# prints 4
    print length($addr2),"\n";	# prints 7

You can basically thank Ilya for whacking us upside the head till we
made it work this way.

Larry



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