Garrett wrote:

   > It almost feels like grep could have been written like this (in
   > another life):  @a = grep (@b) { $_ > 2 or last }

http://www.csse.monash.edu.au/~damian/TPC/2000/Romana/perligata.html

;-)

   
   > While I'm at it, I'm curious as to why:
   > 
   > $a = 2;
   > @b = (1, 2, 3, 2, 1));
   > @a = grep({ { $_ > $a and last} } @b);
   > 
   > results in an exception?

You mean, apart from the two syntax errors? ;-)

It's because the DWIMmer interprets the block:

        { { $_ > $a and last} }

as an anonymous block (the outer braces) containing an anonymous hash
constructor (the inner braces). Try this instead:

        { for(1){ $_ > $a and last} }


Damian

Reply via email to