[Chicago-talk] Odd number of elements in hash assignment
Richard Reina
gatorreina at gmail.com
Tue Aug 18 08:28:14 PDT 2015
When I use the code below I get:
Odd number of elements in hash assignment at Conxtn.pm line 29.
I have read about this in perlmonks but still don't get why it's happening
here because as
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?
Thanks
use Conxtn;
my $desired_db = 'user_opps';
my $con_object = Conxtn->new(db => $desired_db);
package Conxtn;
use DBI;
use strict;
use warnings;
#############################
sub new {
#############################
my ( $class, %args ) = @_;
bless {
_db_name => $args{'db'},
_server => $args{'server'},
}, $class;
#######################
} # end of sub new
######################
########################
sub connect {
########################
my ( $self, %args ) = @_;
my $server; # db server
open MICLAVE, "/home/richard/Dancer2/MyApp/pass" or die "$!";
chomp (my ($user, $clave) = <MICLAVE>);
close MICLAVE;
# select a server for a connection
unless ( defined($self->{_server}) ) {
$server = '127.0.0.1'; ### enter server IP HERE
}
my $dbh =
DBI->connect("DBI:mysql:database=$self->{_db_name};$server",$user,$clave);
return $dbh;
################################
} # end of sub connect
###############################
1;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20150818/b8d6b1ce/attachment.html>
More information about the Chicago-talk
mailing list