Re: Perl won't eval PgSQL boolean value

From: "Andrew Snow" <andrew(at)modulus(dot)org>
To: "'Randall Perry'" <rgp(at)systame(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Perl won't eval PgSQL boolean value
Date: 2001-09-03 17:06:32
Message-ID: 000601c1349a$c7e11730$fa01b5ca@avon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Randall Perry
> Sent: Monday, 3 September 2001 10:01 AM
> To: pgsql-general(at)postgresql(dot)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(at)systame(dot)com
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2001-09-03 17:21:51 Re: Adding a Foreign Key
Previous Message Nigel Gilbert 2001-09-03 16:54:27 European date format option