Re: search always returns an iterator

[prev] [thread] [next] [Date index for 2005/05/06]

From: Cees Hek
Subject: Re: search always returns an iterator
Date: 03:35 on 06 May 2005
On 5/5/05, Dana Hudes <dhudes@xxxxxx.xxxx> wrote:
> @models =3D (Webcontent::Tables::Model->search(%model_node))||die "model =
not found";
>=20
> above copied and pasted from my code.

In the above case, the || has higher precedence than the =3D, so the
line effectively evaluates like this:

@models =3D ( (Webcontent::Tables::Model->search(%model_node)) || die
"model not );

And hence the || is what forces scalar context.

If you used the 'or' operator instead like I mentioned in my post
above, it ends up evaluating like this:

( @models =3D Webcontent::Tables::Model->search(%model_node) ) or die
"model not );

This is because '=3D' has higher precedence than 'or'.  See the perlop
manpage for more info on operator precedence.

- Cees

search always returns an iterator
Dana Hudes 23:58 on 05 May 2005

Re: search always returns an iterator
Michael G Schwern 00:35 on 06 May 2005

Re: search always returns an iterator
Cees Hek 01:39 on 06 May 2005

Re: search always returns an iterator
Dana Hudes 02:53 on 06 May 2005

Re: search always returns an iterator
Perrin Harkins 02:57 on 06 May 2005

Re: search always returns an iterator
Dana Hudes 03:11 on 06 May 2005

Re: search always returns an iterator
Cees Hek 03:35 on 06 May 2005

Generated at 06:54 on 17 May 2005 by mariachi v0.52