develooper Front page | perl.perl5.porters | Postings from July 2008

Re: split in scalar context [was: Alarums and Excursions]

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
July 29, 2008 10:38
Subject:
Re: split in scalar context [was: Alarums and Excursions]
Message ID:
20080729173814.GH9326@klangraum.plasmasturm.org
* Abigail <abigail@abigail.be> [2008-07-29 12:45]:
> On Tue, Jul 29, 2008 at 11:05:27AM +0100, Nicholas Clark wrote:
> > By which you mean remove the assignment to @_, and the
> > warning, but keep the behaviour demonstrated above working?
> 
> That would be quite useful, IMO, as the following secret
> operator doesn't work for split:
> 
>     $words +=()= split;
> 
> It's one of the few places where perl incorrectly outsmarts the
> programmer.

Do note that you can still beat perl at its own game:

    $words += map 1, split;

-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>

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