Re: [CDBI] cdbi objects evaluating as false

Matt S Trout <dbix-class-uY5y5/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
On 25 Nov 2006, at 17:20, Aaron Trevena wrote:

> Hi all,
>
> I'm finding that when I do :
>
> while (my $object = $iterator->next) {
> ..
> }
>
> .. the loop never happens because 'my $object = $iterator->next' seems
> to be false.
>
> instead I have to do :
>
> my $object = $iterator->next();
> while (defined $object && $object->pk) {
>  . . .
>  $object = $iterator->next();
> }

What's wrong with

while (defined (my $object = $iterator->next)) {
   ...
}

?

In general you want to do that anyway with stuff that might stringify  
just in case the stringification turns out to be an expensive  
operation or whatever ...
-- 
Matt S Trout, Technical Director, Shadowcat Systems Ltd.
Offering custom development, consultancy and support contracts for  
Catalyst,
DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for  
details.
+ Help us build a better perl ORM: http://dbix- 
class.shadowcatsystems.co.uk/ +
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.