Multiple choice technology programming languages

Which line of code represents the correct syntax to establish a reference to a database handle?

  1. $dbh = DBI::connect("dbi:mysql:myPhoneBook");
  2. $dbh = DBD:->connect("dbi::mysql::myPhoneBook");
  3. $dbh = DBD::connect("mysql:dbi:myPhoneBook");
  4. $dbh = DBI->connect("dbi:mysql:myPhoneBook");
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The correct Perl DBI syntax is DBI->connect() with the DSN string 'dbi:mysql:myPhoneBook'. Options A and B incorrectly use static (::) instead of arrow (->) syntax. Option C has the wrong DSN format (mysql:dbi instead of dbi:mysql). The DBI module uses object-oriented syntax with the arrow operator.