An Introduction to Class::DBI - Bonus Material 49

Class::DBI Gotchas

Searching context: scalar/list

  • What search() and friends return depends on context

    • in list context they return a list of objects

          my ($kevin_bacon) = FilmBuff::Person->search(name => 'Kevin Bacon');
      
    • in scalar context they return an iterator object

          my $iterator = FilmBuff::Person->search(name => 'Kevin Bacon');
      
          my $kevin_bacon = $iterator->next;
      

 

YAPC::Canada << Previous | Index | Next >>
Copyright © 2003 Michael Graham