Re: print values out of a hash

2003-11-12 Thread R. Joseph Newton
Christiane Nerz wrote: > Andrew Gaffney wrote: > > > James Edward Gray II wrote: > > What you probably want is: > > > > foreach (keys %hash) { > > print "$_ => $hash{$_}\n"; > > } > > > oh nice - like that I get all keys and the corresponding values printed.. > But I only wanted to get all value

Re: print values out of a hash - filling the hash

2003-11-12 Thread John W. Krahn
Christiane Nerz wrote: > > Good morning! Hello, > Thx for your help.. > > The problem seems to lay in "filling the hash". > But I can't see why. > > I want to compare two fasta-files, more precisely the IDs of two sets > of sequences. I take it that the ID is everything between ' >' and "\n"

Re: print values out of a hash

2003-11-12 Thread John W. Krahn
[ Please do not top-post. TIA ] Christiane Nerz wrote: > > Nope - 'cause if I print out the values key for key, I get all four: > > my $array = keys %hash; $array is a scalar and holds a single value. It is not related to @array in any way. > print $hash{$array[0]}; > print"\n"; > print $ha

Re: print values out of a hash - got the faults

2003-11-12 Thread drieux
On Wednesday, Nov 12, 2003, at 02:15 US/Pacific, Christiane Nerz wrote: Hi everybody! I got the mistakes - no bugs but simple human errors ;-) My program wasn't working correctly, because two hashes wasn't filled properly and the reason for the miraculous different output of the values of that

Re: print values out of a hash - filling the hash

2003-11-12 Thread Christiane Nerz
Good morning! Thx for your help.. The problem seems to lay in "filling the hash". But I can't see why. I want to compare two fasta-files, more precisely the IDs of two sets of sequences. Each file looks like: >gi|13699918|dbj|BAB41217.1|. MSEKEIWEKVLEIAQEKLSAVSYSTFLKDTELYTIKDGEAIVLSSIPFNANWL

Re: print values out of a hash

2003-11-12 Thread Christiane Nerz
oh nice - like that I get all keys and the corresponding values printed.. But I only wanted to get all values :-) Jane Andrew Gaffney wrote: James Edward Gray II wrote: On Nov 11, 2003, at 1:47 PM, Christiane Nerz wrote: Hi! If I want to print out every value of a hash, what's wrong with doing

Re: print values out of a hash

2003-11-12 Thread Christiane Nerz
jepp - all four are there.. I really don't understand it. thx so far - I have to finish for today - my little baby-son is crying :-( Jane ... As near as I can tell, the above two chunks of code have identical effects. If you put the first chunk in the program EXACTLY where the foreach() loop

Re: print values out of a hash

2003-11-12 Thread Christiane Nerz
Nope - 'cause if I print out the values key for key, I get all four: my $array = keys %hash; print $hash{$array[0]}; print"\n"; print $hash{$array[1]}; print"\n"; print $hash{$array[2]}; print"\n"; print $hash{$array[3]}; With the code foreach (keys %hash) { print $hash{$_}; print

print values out of a hash - got the faults

2003-11-12 Thread Christiane Nerz
Hi everybody! I got the mistakes - no bugs but simple human errors ;-) My program wasn't working correctly, because two hashes wasn't filled properly and the reason for the miraculous different output of the values of that hash was a simple typo - I typed once hash_fasta1 and the second time

Re: print values out of a hash

2003-11-11 Thread John W. Krahn
Christiane Nerz wrote: > > Hi! Hello, > If I want to print out every value of a hash, what's wrong with doing it > like that: > > foreach (keys %hash) { > print $hash{$_}; > print "\n";} Nothing wrong with that but if you just want the values then use values() instead of keys(). for

Re: print values out of a hash

2003-11-11 Thread drieux
On Tuesday, Nov 11, 2003, at 11:47 US/Pacific, Christiane Nerz wrote: Hi! If I want to print out every value of a hash, what's wrong with doing it like that: foreach (keys %hash) { print $hash{$_}; print "\n";} Why do I only get one value??? probably because there is only One Value in

Re: print values out of a hash

2003-11-11 Thread david
James Edward Gray II wrote: > On Nov 11, 2003, at 2:08 PM, Christiane Nerz wrote: > >> Nope - 'cause if I print out the values key for key, I get all four: >> >> my $array = keys %hash; $array is a scalar, which gets the number of keys in %hash. not the actual keys in %hash. you probably want m

Re: print values out of a hash

2003-11-11 Thread James Edward Gray II
If you would like to post more of your code, I would be happy to take a look at it. James On Nov 11, 2003, at 2:27 PM, Christiane Nerz wrote: jepp - all four are there.. I really don't understand it. thx so far - I have to finish for today - my little baby-son is crying :-( Jane ... As near

Re: print values out of a hash

2003-11-11 Thread James Edward Gray II
On Nov 11, 2003, at 2:08 PM, Christiane Nerz wrote: Nope - 'cause if I print out the values key for key, I get all four: my $array = keys %hash; print $hash{$array[0]}; print"\n"; print $hash{$array[1]}; print"\n"; print $hash{$array[2]}; print"\n"; print $hash{$array[3]}; With the code foreach

Re: print values out of a hash

2003-11-11 Thread Andrew Gaffney
James Edward Gray II wrote: On Nov 11, 2003, at 1:47 PM, Christiane Nerz wrote: Hi! If I want to print out every value of a hash, what's wrong with doing it like that: foreach (keys %hash) { print $hash{$_}; print "\n";} Why do I only get one value??? I don't seen anything wrong with y

Re: print values out of a hash

2003-11-11 Thread James Edward Gray II
On Nov 11, 2003, at 1:47 PM, Christiane Nerz wrote: Hi! If I want to print out every value of a hash, what's wrong with doing it like that: foreach (keys %hash) { print $hash{$_}; print "\n";} Why do I only get one value??? I don't seen anything wrong with your code. I believe there is

print values out of a hash

2003-11-11 Thread Christiane Nerz
Hi! If I want to print out every value of a hash, what's wrong with doing it like that: foreach (keys %hash) { print $hash{$_}; print "\n";} Why do I only get one value??? Jane -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]