my $dblinks = \'\';
$dblinks = $dbh->selectcol_arrayref(\"select db_link from db_links where ticket=\\\'LOW\\\'\");
my $success = 0;
for my $dblink (@$dblinks) {
$s
Simple, really, you assign the handle returned by the connect
call to $l_dbh
but invoke a method on $dbh
. You must use strict.
The database handle $dbh
is not defined which means the connection failed. You should either check return values of your calls, or specify { RaiseError => 1}
in the connect
call to find out the reason.
Further, there is no reason to prefix every sub invocation with &
: Use ConnectFailed( )
instead of &ConnectFailed( )
, unless you know the effect of prefixing a sub invocation with &
and desire to have that effect.
From perldoc perlsub:
A subroutine may be called using an explicit
&
prefix. The&
is optional in modern Perl, as are parentheses if the subroutine has been predeclared. The&
is not optional when just naming the subroutine, such as when it's used as an argument todefined()
orundef()
. Nor is it optional when you want to do an indirect subroutine call with a subroutine name or reference using the&$subref()
or&{$subref}()
constructs, although the$subref->()
notation solves that problem.... If a subroutine is called using the
&
form, the argument list is optional, and if omitted, no@_
array is set up for the subroutine: the@_
array at the time of the call is visible to subroutine instead. This is an efficiency mechanism that new users may wish to avoid. (emphasis added).