<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Vanderbrew &#187; Perl</title>
	<atom:link href="http://vanderbrew.com/blog/category/code/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://vanderbrew.com/blog</link>
	<description>Beer, Food, Code, Writing, Creativity, Life</description>
	<pubDate>Thu, 16 Oct 2008 07:10:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>do {} until is not a loop block</title>
		<link>http://vanderbrew.com/blog/2006/01/12/do-until-is-not-a-loop-block/</link>
		<comments>http://vanderbrew.com/blog/2006/01/12/do-until-is-not-a-loop-block/#comments</comments>
		<pubDate>Fri, 13 Jan 2006 00:39:53 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/01/12/do-until-is-not-a-loop-block/</guid>
		<description><![CDATA[I just learned something&#8230;
It&#8217;s very frustrating to have two very similar blocks of code where one works and the other doesn&#8217;t. The gist of my problem was this - two blocks almost exactly like the block below.

do
{
  if ($some_external_condition) {
    $result = subroutine();
    last if !defined $result;
  [...]]]></description>
			<content:encoded><![CDATA[<p>I just learned something&#8230;</p>
<p>It&#8217;s very frustrating to have two very similar blocks of code where one works and the other doesn&#8217;t. The gist of my problem was this - two blocks almost exactly like the block below.</p>
<pre><code>
do
{
  if ($some_external_condition) {
    $result = subroutine();
    last if !defined $result;
  }
} until $some_other_external_condition
</code></pre>
<p>One of them ran just fine. The other one was throwing a</p>
<pre><code>Can't "last" outside a loop block</code></pre>
<p>runtime error.</p>
<p>Huh? How come one works and one doesn&#8217;t? I dug out the trusty Camel Book and looked up a do loop. Huh? What do you mean, it&#8217;s not a loop? How come my other block of code works just fine?</p>
<p>Takes a closer look - doh! It&#8217;s a runtime error! My first chunk of code never reaches the <code>last</code> call because of the external condition. My second one does reach it.</p>
<p>Oh, well. I hope that this helps someone else with a similar problem&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/01/12/do-until-is-not-a-loop-block/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
