develooper Front page | perl.perl5.porters | Postings from June 2015

Re: scalar sort $scalar

Thread Previous | Thread Next
From:
Eric Brine
Date:
June 28, 2015 22:34
Subject:
Re: scalar sort $scalar
Message ID:
CALJW-qFu7i2NSf5AU-9HH4MqatcybOOxrWm5atsTK5cksUZ0pQ@mail.gmail.com
On Sun, Jun 28, 2015 at 4:43 AM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:

> Would sorting a scalar be a logical behavior or would it break things
>
> $ perl -wE'say reverse "bdca"'
> bdca
> $ perl -wE'say scalar reverse "bdca"'
> acdb
>
> $ perl -wE'say sort "bdca"'
> bdca
> $ perl -wE'say scalar sort "bdca"'
> Useless use of sort in scalar context at -e line 1.
> Use of uninitialized value in say at -e line 1.
>
>
> That could easily be transformed into producing
> $ perl -wE'say scalar sort "bdca"'
> abcd
>

This very aspect of `reverse` causes headaches. It shouldn't serve as a
model.

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