develooper Front page | perl.fwp | Postings from May 2012

Re: seeking golfing advice

Mike Erickson
May 16, 2012 06:41
Re: seeking golfing advice
Message ID:
On 05/16/2012 07:46 AM, damien krotkine wrote:
> Hi all,
> thanks for the quick answers :)
> first of all, despite my attempt to clear things up with an example, I
> failed :)  What I wante is "every other element, beginning with the
> first", so :
> ( 'foo', 3, 42, 'bar) should become ( 'foo', 42).

If you don't care about order, but just want those elements, you can 
also do:


{@a}    being a hash ref constructed from @a
%{ }    dereferencing that hash ref
keys    pulling out the keys, ie. the odd elements of the orig. list


Mike Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About