in reply to DBI->connect fails when password variable used

The code in DBI.pm that spits that error message is :
sub connect { ... Carp::croak('Usage: $class->connect([$dsn [,$user [,$passwd [,\%at +tr]]]])') if (ref $old_driver or ($attr and not ref $attr) or ref $pass);
In your case, when you use $passwd, is that a scalar or ref ?

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992

Replies are listed 'Best First'.
Re^2: DBI->connect fails when password variable used
by fmagee (Novice) on Oct 27, 2014 at 15:29 UTC
    Thanks for the reply, Larry and I apologize for the delay getting back to you. That $passwd is a scalar. I've tried using, "connect($dsn,$user,$passwd)" as well as "connect("DBI:mysql:servers", "my uid", "mypasswd", {'RaiseError' => 1})" and the only thing that works is the hardcoded data as in the latter example. I've tried some of the other suggestions submitted without any luck so far. I would be happy to have the script prompt me for my password and be able to pass it in $passwd but haven't gotten that to work either. Thanks again for your suggestions. Fred

      How do you set $passwd?

      If you're reading the string from the user, most likely, that string still has a newline at its end, which you might want to remove:

      $passwd =~ s/\s*$//; # Remove all whitespace from the end of the passw +ord
        Thanks, Corion. That works like a champ.