<div dir="ltr"><div>Your example shows how you created the $con_object but how are you calling the connect method after that?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 10:28 AM, Richard Reina <span dir="ltr"><<a href="mailto:gatorreina@gmail.com" target="_blank">gatorreina@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">When I use the code below I get:<br><br>Odd number of elements in hash assignment at Conxtn.pm line 29.<br><div>I have read about this in perlmonks but still don't get why it's happening here because as <br></div><div>far as I know I am not innitializing my hash with undef.  Can anyone tell me how I can correct so that I do not get this warning? <br><br></div><div>Thanks<br></div><div><br><br></div><div>   use Conxtn;<br></div><div><br>   my $desired_db = 'user_opps';<br>   my $con_object = Conxtn->new(db => $desired_db);<br><br><br><br><br><br><br><br>package Conxtn;<br><br>use DBI;<br>use strict;<br>use warnings;<br><br><br>#############################<br>sub new {<br>#############################<br><br>    my ( $class, %args ) = @_;<br>    <br>    bless {<br><br>    _db_name => $args{'db'},<br>    _server => $args{'server'},<br><br>    }, $class;<br><br>#######################<br>} # end of sub new<br>######################<br><br>########################<br>sub connect {<br>######################## <br><br>    my ( $self, %args ) = @_;<br>    my $server; # db server<br><br>    open MICLAVE, "/home/richard/Dancer2/MyApp/pass" or die "$!";<br>    chomp (my ($user, $clave) = <MICLAVE>);<br>    close MICLAVE;    <br><br>    # select a server for a connection<br>    unless ( defined($self->{_server}) )  {<br>     $server = '127.0.0.1'; ### enter server IP HERE<br>    }<br><br>    my $dbh = DBI->connect("DBI:mysql:database=$self->{_db_name};$server",$user,$clave);<br><br>    return $dbh;<br><br>################################<br>} # end of sub connect<br>###############################<br><br>1;<br><br></div></div>
<br>_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" rel="noreferrer" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br></blockquote></div><br></div>