Each database connection will be represented as a separate database handle $dbh
Clearly you could write a subroutine that disconnects from all connected database handles, as long as your list of connected databases is always the same
I'm not sure why you're fixating on the connection strings. Presumably you mean the DSNs (Data Source Names) that you used in the call to DBI->connect? They are simply parameters to the connection operation and a database handle cannot be identified after the fact from its original DSN
Issuing rollback() due to DESTROY without explicit disconnect()
This implies that you are using transactions. The best way would be to call rollback or commit yourself to end the transaction. It's a bad idea to leave a transaction open when the program terminates as you are relying on the default behaviour of the database driver
The documentation for DBI::disconnect says this
Generally, if you want your changes to be committed or rolled back when you disconnect, then you should explicitly call "commit" or "rollback" before disconnecting.
You will also get the same warning if you call disconnect while a transaction is still open, so a commit or rollback is definitely the correct method
It is fine to let Perl's destruction sequence implcitly disconnect all database handles as long as no transactions are left open at the time