[Dbix-class] Problem getting data from resultset
Patrick Meidl
patrick at pantheon.at
Sat Jul 7 10:19:04 GMT 2012
On Fri, Jul 06 2012, Patrick Meidl <patrick at pantheon.at> wrote:
> On Fri, Jul 06 2012, Kenneth S Mclane <ksmclane at us.ibm.com> wrote:
>
> > > Subject:
> > >
> > > Re: [Dbix-class] Problem getting data from resultset
> > >
> > >
> > > foreach my $method (split(/\./, $field)) {
> > > last unless ($val);
> > > $val = $val->$method;
> > > }
> > >
> > > should solve this.
> > >
> > That just causes an infinite loop somewhere.
>
> unless you modifiy the iteration list inside your loop, you can't get an
> infinite loop with foreach.
[...]
> foreach my $method (split(/\./, $field)) {
> if (defined($val) and ref($val) and $val->can($method)) {
> $val = $val->$method;
> } else {
> # this is not required, but shortcuts the processing
> last;
> }
> }
looking back at your original code, I saw that this loop is inside an
outer loop over your resultset. so to break the inner loop, you will
have to name it:
METHOD:
foreach my $method (split(/\./, $field) {
...
last METHOD;
}
patrick
--
Patrick Meidl ........................ patrick at pantheon.at
Vienna, Austria ...................... http://gplus.to/pmeidl
More information about the DBIx-Class
mailing list