Re: exception handling in plperlu

From: Douglas McNaught <doug(at)mcnaught(dot)org>
To: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>
Cc: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: exception handling in plperlu
Date: 2007-03-16 15:17:33
Message-ID: 87hcsl43qq.fsf@suzuka.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Jasbinder Singh Bali" <jsbali(at)gmail(dot)com> writes:

> just wondeng why doesn't it let me put
> my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;",
> "", "");
> in eval
>
> says
> Global symbol "$dbh" requires explicit package name at line <where ever dbh is
> used>

The my() variable goes out of scope when the eval {} is done. Declare
the variable outside the eval {}:

my $dbh;

eval { $dbh = connect(...) };

eval { $dbh->prepare(...:) };

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2007-03-16 15:26:13 Re: pg_dumpall and version confusion
Previous Message Martijn van Oosterhout 2007-03-16 15:08:56 Re: exception handling in plperlu