I am completely new to Perl . I have a Perl script which check connection to a oracle database running in a container . Here is my code
#!/usr/bin/perl
use DBI;
$\="\n";
print "Connecting to DB..";
my $dbh = DBI->connect('dbi:Oracle:host=oracle;sid=ORCLCDB;port=1521', 'books_admin/MyPassword', '',{ RaiseError => 1, AutoCommit => 0 })or die print ("could not connect! $DBI::errstr \n");
Using this script I'm able to connect with oracle database . But this script doesn't give any status output to my terminal . How can i check the script is connected to database?. I know bash has $? for checking the status of previously executed cmd. Do we have something similar in Perl?
Here is what i want Output "Successfully connected to Oracle-db" when the connection is OK and failed status when script can't connect to database
Note:This code give error status to my terminal. My Perl version is v5.16.3