Re: [CDBI] CDBI and grep
[prev]
[thread]
[next]
[Date index for 2006/01/16]
On Mon, Jan 16, 2006 at 11:27:56AM +0100, Rolf Schaufelberger wrote:
> Hi,
> I have a table users and and a table columns,
> users has_a company_id. Now, If I have a expression like
>
> my $user = XY::Users->retrieve(123);
> if ( grep /$user->company_id->id/, ( 1, 2, 3 ) )
>
> i get no match even if the company_id is on of 1,2,3.
> Neither
> if ( grep /$user->company_id/, ( 1, 2, 3 ) )
> nor
> if ( grep /"$user->company_id"/, ( 1, 2, 3 ) )
> match,but
> my $id = $user->company_id->id;
> if ( grep /$id/, ( 1, 2, 3 ) )
> does. I have no idea why the other expressions above fail.
> There is no stringify function for company.
This has nothing to do with CDBI, it is simply a matter of how perl
interpolates. From perlop:
For constructs that do interpolate, variables beginning with
""$"" or ""@"" are interpolated. Subscripted variables such
as $a[3] or "$href->{key}[0]" are also interpolated, as are
array and hash slices. But method calls such as
"$obj->meth" are not.
You might also like to consider perldoc -q contain.
--
Paul Johnson - paul@xxxx.xxx
http://www.pjcj.net
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
|
|
Re: [CDBI] CDBI and grep
Paul Johnson 12:16 on 16 Jan 2006
|