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

Re: key/value hash and index/valuse array slices syntax

Thread Previous | Thread Next
From:
David Nicol
Date:
June 10, 2013 18:36
Subject:
Re: key/value hash and index/valuse array slices syntax
Message ID:
CAFwScO_YMYat-ym9GF7nBbyZMxt7RkGPUagZYG1jsTo1J2fDAA@mail.gmail.com
On Mon, Jun 10, 2013 at 6:33 AM, Dave Mitchell <davem@iabyn.com> wrote:

> On Sun, Jun 09, 2013 at 06:51:23PM -0500, David Nicol wrote:
> > one of the perl6 RFCs suggested allowing a regex as a hash index
> >
> >    @hash{/REGEX/}
> >
> > to mean
> >
> >   @hash{ grep /REGEX/, keys %hash }
>
> but that syntax already has a meaning:
>
>     %h = qw(aa 1 bb 2 cc 3);
>     $_ = 'aa bb';
>     print @h{/(\w+)/};  # prints 1
>     print @h{/(\w+)/g}; # prints 12
>

How about regexen without any captures in them, then?

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