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

Re: seeking golfing advice

Ronald J Kimball
May 16, 2012 08:22
Re: seeking golfing advice
Message ID:
On Wed, May 16, 2012 at 04:40:40AM -0700, John Douglas Porter wrote:
> And of course, use grep, as others have said.
> @list[ grep !$_%2, 0..$#list ];
> that gets you every other element, beginning with the first.

! has higher precedence than %, so this actually gets you just the
first element.

You need to add parentheses to get the correct result:


There are a couple ways to shave a character from that:


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