MrTEE has asked for the wisdom of the Perl Monks concerning the following question:
This code works, however I get errors when I run it and they reference line 36. I get these Use of uninitialized value in numeric ne (!=) at line 36 of the script. When I take of use strict and use warnings - but we don't want to do that. I have to do something, ligically with line 36. Use strict does not like this line: "if ($spec_hash{$exch}{$symbol} != 1) {"
Use of uninitialized value in numeric ne (!=) at ./pure_penny_golf_wex +tend.forBrodinpl line 36. etds_extend surplus specialist name: delete from etds_extend where e_r +isk_symbol = 'WINN' and e_exch_dest = 'XISX' Use of uninitialized value in numeric ne (!=) at ./pure_penny_golf_wex +tend.forBrodinpl line 36. etds_extend surplus specialist name: delete from etds_extend where e_r +isk_symbol = 'WTR_S5F4' and e_exch_dest = 'XISX'
WINN and WTR_S5F4 are in the %extend_hash
This is the %extend_hash$VAR1 = {'6' => {'IACI' => { 'ARCX' => { 'specialist' => '1', 'penny' +=> '0 }}, 'MCHP' => { 'ARCX' => { 'specialist' => '1', 'penny' +=> '0'}}, 'BC' => { 'AMXO' => { 'specialist' => '1', 'penny' +=> '0'}}, 'WINN' => { 'XISX' => { 'specialist' => '1', 'penny' +=> '0'}}, 'WTR_S5F4' => { 'XISX' => { 'specialist' => '1', 'penny' +=> '0'}}, 'XLY' => { 'CS' => { 'specialist' => '0', 'penny' +=> '1'}} } };
this is the spec_hash - WINN and WTR_S5F4 are not in the %spec_hash
$VAR1 = { 'XISX' => { 'FCEL'=> 1, 'GPS' => 1, 'MCO' => 1, 'DPZ' => 1, 'ENTG' => 1, 'PDS' => 1 } };
this is the script.
1 #!/sbcimp/perl/bin/perl 2 #/sbcimp/etds_extend.pl 3 use DBI ; 4 use strict ; 5 use warnings; 6 7 use Data::Dumper; 8 my %extend_hash = (); 9 my $dbUser = 'nice'; 10 my $dbPass = 'try'; 11 my $dbSid = 'THE_world'; 12 my $dbh = DBI->connect("dbi:Oracle:$dbSid","$dbUser","$dbPass") o +r die( "Couldn't connect: $!" ); 13 my $query = "select level_id,e_risk_symbol,e_exch_dest,penny,speci +alist from etds_extend"; 14 if(!$dbh) { 15 print "Error connecting to DataBase; $DBI::errstr\n"; 16 } 17 my $cur_msg = $dbh->prepare($query) or die "\n\nCould not prepare +statement: ".$dbh->errstr; 18 $cur_msg->execute(); 19 while (my @row=$cur_msg->fetchrow_array) { 20 $extend_hash{$row[0]}{$row[1]}{$row[2]}{'penny'}=$row[3]; 21 $extend_hash{$row[0]}{$row[1]}{$row[2]}{'specialist'}= +$row[4]; 22 } 23 my %spec_hash=(); 24 $query = "select e_risk_symbol from gsd_etds where level_name='EXC +H_CS' and e_exch_dest='XISX' and e_symbol_comment in ('Bin_6','Bin_56 +')"; 25 if(!$dbh) { print "Error connecting to DataBase; $DBI::errstr\n"; +} 26 $cur_msg = $dbh->prepare($query) or die "\n\nCould not prepare + statement: ".$dbh->errstr; 27 $cur_msg->execute(); 28 while (my @row=$cur_msg->fetchrow_array) { 29 $spec_hash{'XISX'}{$row[0]}=1; 30 } 31 #print Dumper(\%spec_hash) ; 32 #print Dumper(\%extend_hash) ; 33 foreach my $symbol (sort keys %{$extend_hash{6}}) { 34 foreach my $exch (sort keys %{$extend_hash{6}{$symbol}}) { 35 if ($extend_hash{6}{$symbol}{$exch}{'specialist'}) { 36 if ($spec_hash{$exch}{$symbol} != 1) { 37 my $line="etds_extend surplus specialist name: del +ete from etds_extend where e_risk_symbol = '$symbol' and e_exch_dest += '$ exch'"; 38 print "$line\n"; 39 #push(@error_array,$line); 40 } 41 } 42 } 43 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of uninitialized value
by GrandFather (Saint) on Sep 10, 2014 at 03:31 UTC | |
|
Re: Use of uninitialized value
by tobyink (Canon) on Sep 10, 2014 at 07:26 UTC | |
|
Re: Use of uninitialized value
by thewebsi (Scribe) on Sep 10, 2014 at 05:43 UTC |