http://qs321.pair.com?node_id=1154647

biologistatsea has asked for the wisdom of the Perl Monks concerning the following question:

Below is part of a script that I think should read a file into a hash, so I can look up the record using the key from other parts of the program. The print statements include are for trying to find out what's wrong! The program finds the name successfully (based on the print in the if loop), and creates the hash with the right values, but the keys are always empty (based on the output of the while loop that prints the hash)

open (NOV, '<', $novo); my %denovo; while (my $line = <NOV>){ chomp $line; if ($line =~ /([^,]*)$/){ my $name = "$1"; print "name is $name\n"; $denovo{$name} = "$line"; } } print "hash denovo is:\n"; while( my( $key, $value ) = each %denovo ){ print "$key: $value\n"; } close NOV;

I've tried changing the presence of / types of commas around $name when defining each hash entry. The keys should look like following: R2b.9138.9138.2(intensity=1341005.0692)_2 so I've tried using simpler names in case there were some illegal characters or something - but nothing works! I think I must be misunderstanding something fairly fundamental. Any help would be enormously appreciated.