<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 <<a href="mailto:romkey@romkey.com">romkey@romkey.com</a>> wrote on 07/09/2012
11:48:34 AM:<br>
<br>
> Re: [Dbix-class] Problem getting data from resultset</font></tt>
<br><tt><font size="2">> <br>
> On Jul 9, 2012, at 12:27 PM, Kenneth S Mclane wrote:</font></tt>
<br><tt><font size="2">> while (my @data =
$sr->next) { </font></tt>
<br><tt><font size="2">> <br>
> The problem is this line of code. @data in a scalar context will <br>
> evaluate to the index of the last element of the array (-1 if the
<br>
> array is empty) (assuming you haven't changed the index of the first<br>
> element of arrays). The loop will succeed even when $sr->next <br>
> returns undefined.</font></tt>
<br><tt><font size="2">> <br>
> Try:</font></tt>
<br><tt><font size="2">> <br>
> while( my $data_scalar = $sr->next ) {</font></tt>
<br><tt><font size="2">> my @data = $data_scalar->all;</font></tt>
<br><tt><font size="2">> <br>
> instead</font></tt>
<br><tt><font size="2">> <br>
</font></tt>
<br><tt><font size="2">I actually changed it to this: my @data = $sr->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->next gives you the next row</div><div><br></div><div>$sr->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->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>