parse_dsn()
DBI->parse_dsn($data_source_name)This function returns the components of the DBI Data Source Name (DSN) values: the scheme
(dbi); the driver
($ENV{DBI_DRIVER}); an optional attribute string; a
reference to a hash with the attribute names and values; and the DBI
DSN string. Here is an example:
... use DBI; my $dsn = "DBI:mysql:database=bookstore;host=localhost;port=3306"; my $dbh = DBI->connect ($dsn,$user,$pwd) or die DBI->errstr; my ($scheme, $driver, $attr_string, $attr_hash, $driver_dsn) = DBI->parse_dsn($dsn); print "DSN: ($scheme, $driver, $attr_string, $attr_hash, $driver_dsn) \n";
Here are the results:
DSN: (dbi, mysql, , , database=bookstore;host=localhost;port=3306)