From: | merlyn(at)stonehenge(dot)com (Randal L(dot) Schwartz) |
---|---|
To: | Douglas McNaught <doug(at)mcnaught(dot)org> |
Cc: | "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>, "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 16:03:31 |
Message-ID: | 86odmtkwfg.fsf@blue.stonehenge.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>>>>> "Douglas" == Douglas McNaught <doug(at)mcnaught(dot)org> writes:
Douglas> my $dbh;
Douglas> eval { $dbh = connect(...) };
Since eval returns its value (or undef if $@ has the error), you can shorten
this to:
my $dbh = eval { DBI->connect(...) };
and now either look at $@ (if you want to distinguish exception vs normal) or
just defined $dbh (if you want to know if you have a useful handle or not).
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn(at)stonehenge(dot)com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
From | Date | Subject | |
---|---|---|---|
Next Message | Reece Hart | 2007-03-16 17:18:56 | Re: [SQL] PostgreSQL to Oracle |
Previous Message | Tom Lane | 2007-03-16 15:42:51 | Re: pg_dumpall and version confusion |