<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 9, 2012, at 1:09 PM, Kenneth S Mclane wrote:</div><blockquote type="cite"><tt><font size="2">John Romkey &lt;<a href="mailto:romkey@romkey.com">romkey@romkey.com</a>&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></blockquote><br></div><div>$sr is your resultset</div><div><br></div><div>$sr-&gt;next gives you the next row</div><div><br></div><div>$sr-&gt;all gives you all records</div><div><br></div><div><a href="http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#all">http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#all</a></div><div><br></div><div>in my example $data_scalar-&gt;all will return the values of all the columns in that row - very different from getting all the rows in the resultset</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- john romkey</div><div><span class="Apple-tab-span" style="white-space:pre">        </span><a href="http://romkey.com/">http://romkey.com/</a></div><div><br></div><div><br></div><div><br></div></body></html>