Re: Perl won't eval PgSQL boolean value - Mailing list pgsql-general

From Andrew Snow
Subject Re: Perl won't eval PgSQL boolean value
Date
Msg-id 000601c1349a$c7e11730$fa01b5ca@avon
Whole thread Raw
In response to Perl won't eval PgSQL boolean value  (Randall Perry <rgp@systame.com>)
List pgsql-general
When comparing strings in perl you usually use the eq operator, not ==

e.g.  if($cust_data->{hold} eq 't')

- Andrew



> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Randall Perry
> Sent: Monday, 3 September 2001 10:01 AM
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] Perl won't eval PgSQL boolean value
>
>
> I've got an if statement that checks if a boolean value is true:
>
>     if ($cust_data->{'hold'} eq 't')
>
> But perl will not evaluate the value. $cust_data->{'hold'} is
> taken from a PgSQL boolean field (either t or f). If I use
> the construct above it tell me that 'eq' is not defined
> thinking it's a string.
>
> If I use:
> if ($cust_data->{'hold'} == 't')
>
> I get an error saying $cust_data->{'hold'} is a non-numeric value.
>
> If I do this:
>  if ($cust_data->{'hold'})
>
> it will always evaluate to true whether the value is 't' or 'f'.
>
>
> HELP. How do you evaluate boolean values from PgSQL in Perl?
>
>
> --
> Randy Perry
> sysTame
> Mac Consulting/Sales
>
> phn                 561.589.6449
> mobile email        help@systame.com
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>


pgsql-general by date:

Previous
From: tankgirl@worldonline.es
Date:
Subject: Adding a Foreign key!
Next
From: "Joe Conway"
Date:
Subject: Re: query not using index