Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: $sth = $dbh->prepare($sql) or what?

by greengaroo (Hermit)
on Sep 21, 2012 at 13:15 UTC ( #994900=note: print w/replies, xml ) Need Help??

in reply to $sth = $dbh->prepare($sql) or what?

I would suggest you throw an exception when an error occurs. You don't need if blocks if you do it with objects. Then you wrap this in a try-catch block, see module TryCatch

Basically you "try" your code, you "throw" an exception object when you have an error and you "catch" the error for displaying it elegantly. You catch block should be able to process any kind of exception. You code would be more generic like that.

You can build your own exception classes but I suggest you take a look on CPAN, there is plenty of exception modules.

There are no stupid questions, but there are a lot of inquisitive idiots.
  • Comment on Re: $sth = $dbh->prepare($sql) or what?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994900]
choroba likes the story at the end of the node
[choroba]: reminds me of the days at the bank
[Corion]: Lady_Aleena: Hehe ;-D
[Lady_Aleena]: Corion, it was PerlMonks who kept pushing me to get Linux, so now I know some of the commands to use in word play.
[Corion]: Lady_Aleena: :-D
[Lady_Aleena]: Corion, so do you think the gods would be open to taking over Cookies should I disappear for too long a time?
[Corion]: Lady_Aleena: Yes, I think so, but maybe someone else might also take care of the cookies ;)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-04-26 08:34 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (471 votes). Check out past polls.