How to skip database errors in perl

I've a perl script, in which I need to make multiple database connections in each sub function

DBI->connect(database1, user, passwd);

DBI->connect(database2, user2, passwd2);

sub subFn1()
  my $sel1= DBI->prepare("Select...");
 my $var1 = $sel1->fetchrow();

sub subFn2()
  my $sel2= DBI->prepare("Select...");
 my $var2 = $sel2->fetchrow();

Now, if there is any error or one of the database is down, the program shouldn't exit with error, rather it should continue to the next database connections.
Similarly, if there is any inside the subroutines, it shouldn't die, rather it should continue till the end of the program

How do I achieve this.

Who is Participating?
eval { code to make nonfatal };  warn $@ if $@;
prasen120998Author Commented:
ozo, could you pls elaborate a little bit more, based on the above example
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.