Toby,<div><br></div><div>I&#39;ve noticed this. It&#39;s supposed to be a back-port of a Perl 6 feature.</div><div><br></div><div>I grokked the Perl 6 test suite and fond the following in t/spec/S04-statements/given.t</div>
<div><br></div><div>==================================</div><div><div>    # from apocalypse 4</div><div>    #?rakudo skip &#39;parsefail on each(... ; ...)&#39;</div><div>    {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span># simple example L&lt;S04/&quot;Switch statements&quot; /You don&#39;t have to use an explicit default/&gt;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>for each((&quot;T&quot;, &quot;E&quot;, 5) ; (10, 11, 5)) -&gt; $digit, $expected {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    my $result_a = do given $digit {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>when &quot;T&quot; { 10 }</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>when &quot;E&quot; { 11 }</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>$digit</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>    };</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    my $result_b = do given $digit {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>when &quot;T&quot; { 10 }</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>when &quot;E&quot; { 11 }</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>default  { $digit }</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    };</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    is($result_a, $expected, &quot;result of $digit using implicit default {} is $expected&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    is($result_b, $expected, &quot;result of $digit using explicit default {} is $expected&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>    }</div></div><div>===================================</div><div><br></div><div>So it looks as if this is inconsistently implemented across Perl 6 &amp; 5.</div>
<div><br></div><div>I would&#39;ve thought that Perl 5 should behave the same way. Also it wouldn&#39;t hurt to back-port the &#39;given&#39; tests from rakudo.</div><div>- David</div><div><br><div class="gmail_quote">On Wed, Jun 2, 2010 at 3:16 PM, Toby Corkindale <span dir="ltr">&lt;<a href="mailto:toby.corkindale@strategicdata.com.au">toby.corkindale@strategicdata.com.au</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">An annoyance right now is that the given/when syntax does not return the values in the code block executed, so you can&#39;t use them inside grep,etc.<br>

<br>
Has anyone else noticed a way around that? (Apart from wrapping it in an anonymous subroutine and then returing out of the when blocks)<br>
_______________________________________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org" target="_blank">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br>
</blockquote></div><br></div>