Re: [CDBI] CDBI and grep

[prev] [thread] [next] [Date index for 2006/01/16]

From: Paul Johnson
Subject: Re: [CDBI] CDBI and grep
Date: 12:16 on 16 Jan 2006
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

[CDBI] CDBI and grep
Rolf Schaufelberger 10:27 on 16 Jan 2006

Re: [CDBI] CDBI and grep
Paul Johnson 12:16 on 16 Jan 2006

Generated at 20:45 on 01 Mar 2006 by mariachi v0.52