|
Posted by marko on August 2, 2008, 8:18 am
Please log in for more thread options > On Fri, 01 Aug 2008 21:25:23 -0700, marko wrote:
> > if (undef $dbh) {die "cannot connect to database:$!\n";} else {print
> =A0 ^^^^^^^^^^^^^^^
> > "Success connecting!\n";} my $statement =3D "select count(*) from
>
> Which means: Undefine the $dbh variable; if (undefined value =3D=3D true)
> { die no connect } else { print success };
>
> You probably want:
>
> die "cannot connect to database:$!\n" unless defined $dbh;
> print "Success connecting!\n";
>
> HTH,
> M4
Whoopsie! Thanks. Wow. I gotta say as much as I like perl, it can
really be very unintuitive at times and I think the vast difference
between defined and undef is one of them. undef will change the value
of your variable and defined is a test!
Well, that was obviously my problem. It works now. Thanks.
|