On 10.06.2013 13:33, Dave Mitchell 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 > Right, but @hash{qr/REGEX/} could work. Currently it stringifies the regex object and uses that as a hash key, but that's not very useful IMHO. Would $hash{qr/REGEX/} mean $hash{join $;, grep /REGEX/, keys %hash}? -- Lukas Mai <plokinom@gmail.com>Thread Previous | Thread Next