in reply to Using foreach to process a hash

"keys" will return the keys for a hash, and "values" will return all the values. For what you want to do, "keys" is the most useful - e.g.

use strict; my %hash = ('a'=>'hello', 'b'=>'goodbye', 'c'=>'foobar'); foreach my $key(keys %hash){ # iterates over 'a', 'b' and 'c' print "the value of $key is $hash{$key}\n"; }

One point to note is that the order of the returned keys is not predictable (I get c,a,b in the above example).

Tom Melly, tom@tomandlu.co.uk