<tt><font size=2>John Romkey &lt;romkey@romkey.com&gt; wrote on 07/09/2012
11:48:34 AM:<br>
<br>
&gt; Re: [Dbix-class] Problem getting data from resultset</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; On Jul 9, 2012, at 12:27 PM, Kenneth S Mclane wrote:</font></tt>
<br><tt><font size=2>&gt; &nbsp; &nbsp; &nbsp; &nbsp; while (my @data =
$sr-&gt;next) { </font></tt>
<br><tt><font size=2>&gt; <br>
&gt; The problem is this line of code. @data in a scalar context will <br>
&gt; evaluate to the index of the last element of the array (-1 if the
<br>
&gt; array is empty) (assuming you haven't changed the index of the first<br>
&gt; element of arrays). The loop will succeed even when $sr-&gt;next <br>
&gt; returns undefined.</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Try:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; while( my $data_scalar = $sr-&gt;next ) &nbsp;{</font></tt>
<br><tt><font size=2>&gt; &nbsp; &nbsp; &nbsp; my @data = $data_scalar-&gt;all;</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; instead</font></tt>
<br><tt><font size=2>&gt; <br>
</font></tt>
<br><tt><font size=2>I actually changed it to this: my @data = $sr-&gt;all;
I think this is equivalent isn't it? This does not give me any errors,
but only outputs one row to the file.</font></tt>