note
BrowserUk
<blockquote><i></i></blockquote>
<p>I've always thought of this property of p5 if/elsif/else blocks as the blocks 'leaving behind their last value', analogous to the block of a [do] or [sub]. Whether that is a strictly accurate description of what happens internally doesn't really matter, it's just an aid memoire to my remembering the behaviour.
<p>I've often wished that it was property of <i>all</i> blocks. It could, for example, provide a solution to the problem [LanX] describes in [id://824385]. That of obtaining a (full) list of matches from a global regex.
<P>Something like (the non-working):
<code>
my @filtered = grep{ ... } do{ [ $1, $2 ] while $s =~ m[(.)(.)]g };
</code>
<p>I've also been frustrated that I can't obtain this list directly without going through an intermediary push to an array. Presumably P6 has an answer to this already?
<p>I guess that a different (better) approach in P5 syntax would be another modifier on the regex (perhaps <c>/gg</c>).
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.</div>
<div>"Science is about questioning the status quo. Questioning authority". </div>
<div>In the absence of evidence, opinion is indistinguishable from prejudice.</div>
<div>[http://www.theregister.co.uk/2009/12/03/exploding_donkey/|"I'd rather go naked than blow up my ass"]</div>
</font>
</div></div>
824056
824399