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 the hash?

        my %hash =  qw/ a b c d e f g h/ ;
        
        print "$_ => $hash{$_} \n"
                foreach (sort keys %hash);

will generate:
        a => b
        c => d
        e => f
        g => h


so if your code is only getting ONE iteration through the loop, then %hash has only one key in it.


ciao drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to