I guess there is some application-specific reason that you rejected the notion of a subroutine as a way of simplifying this.
I assume that:
my $DSN2 = "DSN=DATABASE2;UID=sa;PWD=password;";
my $connection2 = new Win32::ODBC("$DSN");
isn't quite what was intended... and illustrates something.
If the script dies "Could not open connection to DSN because of xxxx" it's not clear to me how one can tell which of the two databases is problematic.
It may be deliberate that the printing of the selected rows gives no extra indication of which database they come from.
If it is ever necessary to check three databases, another cut/paste/edit/scrutinize-carefully job will be required.
I suggest that your code fragment would be unlikely to win prizes for style, in any language -- even Perl, for all its quirky wonderfulness. |