<tt><font size=2>Patrick Meidl &lt;patrick@pantheon.at&gt; wrote on 07/09/2012
03:12:07 PM:<br>
<br>
&gt; Subject:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Re: [Dbix-class] Problem getting data from resultset</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; On Mon, Jul 09 2012, John Romkey &lt;romkey@romkey.com&gt; wrote:<br>
&gt; <br>
&gt; &gt; On Jul 9, 2012, at 12:27 PM, Kenneth S Mclane wrote:<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; while (my @data = $sr-&gt;next)
{ <br>
&gt; &gt; <br>
&gt; &gt; The problem is this line of code.<br>
&gt; <br>
&gt; that's correct. this expression will always evaluate to TRUE, so the<br>
&gt; loop won't finish and your code will croak after scalar($st-&gt;all)<br>
&gt; iterations.<br>
&gt; <br>
&gt; &gt; Try:<br>
&gt; &gt; <br>
&gt; &gt; while( my $data_scalar = $sr-&gt;next ) &nbsp;{<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; my @data = $data_scalar-&gt;all;<br>
&gt; <br>
&gt; that's wrong, though. DBIx::Class::Resultset-&gt;next already returns
your<br>
&gt; result row, so the code should be:<br>
&gt; <br>
&gt; while (my $data = $sr-&gt;next) {<br>
&gt; &nbsp; &nbsp; # call accessors on your Accountv object<br>
&gt; &nbsp; &nbsp; ...<br>
&gt; }<br>
&gt; <br>
&gt; HTH<br>
&gt; <br>
&gt; &nbsp; &nbsp; patrick<br>
That did the trick Patrick, thank you. It seems I was way over complicating
it. Here is the working code for posterity:</font></tt>
<br>
<br><tt><font size=2>while ( my $data = $sr-&gt;next ) &nbsp;{ </font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; foreach my $field (@fields) {</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $val = $data;</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach my $method
(split(/\./, $field)) {</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; $val = $val-&gt;$method;</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; $ws-&gt;write($row, $col, $val);</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; $col++;</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; }</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; $col=0;</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; $row++;</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; }</font></tt>
<br><tt><font size=2>Now I am going to see if I can switch back to my regular
rs, but not on this one. I like the idea of walking down to the relationship
accessor so it is truly just one function that handles whatever you throw
at it.<br>
</font></tt>