develooper Front page | perl.perl6.language | Postings from April 2008

given vs for

Thread Next
From:
Nicholas Clark
Date:
April 25, 2008 04:17
Subject:
given vs for
Not being familiar with the big picture design* of Perl 6, I'm not able to
answer this. I assume that there is a clear reason, but what is it?

Nicholas Clark

* Heck, I'm also not familiar with the little bits either.

----- Forwarded message from Ed Avis <eda@waniasset.com> -----

Envelope-to: nick@flirble.org
Delivery-date: Fri, 25 Apr 2008 11:32:50 +0100
Mailing-List: contact perl5-porters-help@perl.org; run by ezmlm
Delivered-To: mailing list perl5-porters@perl.org
Delivered-To: perl5-porters@perl.org
To: perl5-porters@perl.org
From:  Ed Avis <eda@waniasset.com>
Subject:  Re: [perl #53186] Modifying $_ inside 'given'
Date: Fri, 25 Apr 2008 10:32:19 +0000 (UTC)
User-Agent: Loom/3.14 (http://gmane.org/)
X-Loom-IP: 80.169.169.174 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5)

Paul Fenwick <pjf <at> perltraining.com.au> writes:

>for ($foo) {
>	when ($_ < 500)  { ++$_ }
>	when ($_ > 1000) { --$_ }
>	default          { say "Just right $_" }
>}

Ahh... that's exactly what I was looking for.  Thanks.

Makes you wonder why the 'given' keyword was added, when for/when is so close...

-- 
Ed Avis <eda@waniasset.com>


----- End forwarded message -----

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About