<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>i believe you are getting an array-ref because you are calling it in list context via the [ ... ] here.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> my $myalums = [ $c->model('MyDB::Alumni')->search({}, { rows => 20 }) ] ;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>try:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> my $myalums_iter = $c->model('MyDB::Alumni')->search({}, { rows => 20 });</DIV><DIV> while (my $alum = $myalums_iter->next) { ... }</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV><DIV>On Jun 19, 2007, at 11:16 AM, John Goulah wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><BR><BR><DIV><SPAN class="gmail_quote">On 6/19/07, <B class="gmail_sendername">John Napiorkowski</B> <<A href="mailto:jjn1056@yahoo.com">jjn1056@yahoo.com</A>> wrote:</SPAN><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <BR>--- John Goulah <<A href="mailto:jgoulah@gmail.com">jgoulah@gmail.com</A>> wrote:<BR><BR>> If I do something simple like this:<BR>><BR>> my $myalums = [<BR>> $c->model('MyDB::Alumni')->search({}, { rows => 20 <BR>> })<BR>> ] ;<BR>><BR>> and stash it:<BR>> $c->stash->{alumni} = $myalums;<BR>><BR>> I am able to iterate in the template like:<BR>><BR>> [% FOREACH alum IN alumni -%]<BR>> id: [% alum.alumni_id %] <br /><BR>> [% END -%]<BR>><BR>><BR>> But if I try to iterate this in the controller, I<BR>> cannot do something like:<BR>><BR>> while (my $alum = $myalums->next) {<BR> > $c->log->debug("id: ". $alum->alumni_id);<BR>> }<BR><BR>Because ->next isn't a method on an array reference.<BR>You could try derefing via @$myalumns.</BLOCKQUOTE><DIV><BR><BR> I have tried a few things here. I can get this to work:<BR><BR><BR> for my $element (@{$myalums}) {<BR> $c->log->debug("alum:". $element->alumni_id);<BR> }<BR><BR><BR>but not :<BR><BR> while (my $alum = @{$myalums}->next) {<BR> $c->log->debug("id: ". $alum->alumni_id);<BR> }<BR><BR>In this case I get: <BR><PRE><CODE class="error">Can't call method "next" without a package or object reference
</CODE></PRE><BR><BR>I'm assuming I'm just doing something obviously wrong here?<BR><BR>Thanks!<BR>John<BR><BR><BR><BR> </DIV><BR></DIV><BR><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">List: <A href="mailto:Catalyst@lists.rawmode.org">Catalyst@lists.rawmode.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Listinfo: <A href="http://lists.rawmode.org/mailman/listinfo/catalyst">http://lists.rawmode.org/mailman/listinfo/catalyst</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Searchable archive: <A href="http://www.mail-archive.com/catalyst@lists.rawmode.org/">http://www.mail-archive.com/catalyst@lists.rawmode.org/</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Dev site: <A href="http://dev.catalyst.perl.org">http://dev.catalyst.perl.org</A>/</DIV> </BLOCKQUOTE></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>---</DIV><DIV>michael reece :: software engineer :: <A href="mailto:mreece@vinq.com">mreece@vinq.com</A></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>