I have been fighting with this problem for over a week now he really aggravating thing is that I had it working for over a year without problem. have tried everything I can imagine. I've cut the code down to a toy version to isolate the problem and it is no help. For the sake of this issue let's say that I am trying to populate a hash from a space delimited file and then, using a list of keys from another file to iterate over and access each of the values for further use in the program.
#!/usr/bin/ perl \ use strict; use warnings; my %hash = (); my $key = ''; open ACCESSIONS, "fix.txt" or die "Can't open fix.txt: $!\n"; while (my $locus_line = <ACCESSIONS>){ #This is supposed to populate %hash. %hash = split(/\s/, $locus_line); foreach my $k (keys %hash) { # print "$k $accesshash{$k} \n"; } } close ACCESSIONS; open INKEYS, "in.txt" or die "Can't open in.txt: $!\n"; while (my $x = <INKEYS>){ #var is the key whose value I will want to grab for use later in the program. $key = $x; chomp($key); #Some debug lines to check the output by Alex Batko print "Value EXISTS, but may be undefined.\n" if exists $hash{$key}; print "Value is DEFINED, but may be false.\n" if defined $hash{$key}; print "Value is TRUE at hash key $var.\n" if $hash{$key}; print "$key "; print $hash{$var}; print "\n"; } print "\n" . $hash{$var}; print "\n"; close INKEYS; This seems to populate the hash just fine. When trying to access those same hash elements, however, I get various flavors of "Use of uninitialized value in ...." I have even tried to use the same file that I used as input to create the hash to troll for keys to search the hash and get the same problem. Please, can someone help me figure out what I have done wrong. Here are the simplified files: fix.txt a 1 b 2 c 3 d 4 e 5 in.txt a b d e and this is the output I get; $ perl fix.pl Use of uninitialized value in print at fix.pl line 29, <INKEYS> line 1. a Use of uninitialized value in print at fix.pl line 29, <INKEYS> line 2. b Use of uninitialized value in print at fix.pl line 29, <INKEYS> line 3. d Value EXISTS, but may be undefined. Value is DEFINED, but may be false. Value is TRUE at hash key e. e 5 Use of uninitialized value in concatenation (.) or string at fix.pl line 33, <INKEYS> line 4. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/