In article <[EMAIL PROTECTED]>, Rob Dixon wrote: > Well done Kevin! > > Just a couple of points.
Am I surprised? ;-) >> sub pad_keys { >> my $ref = shift; >> if (ref $ref eq "HASH") { >> for my $value (%$ref) { > > This will loop over all the keys and values in the > hash, in the order key1, value1, key2, value2, ... > All you want is the values. You mean that the last line should be: for my $value (values %$ref) { # ? [...] > Finally, there's no need process the values and then the keys > in separate loops. Each execution of either loop corresponds to > a key/value pair so you can write > > foreach (keys) { > modify key; > recurse on value; > } After looking at your example I see what you mean. [...] > next unless (my $new = $_) =~ tr/ /_/; This tests true only if tr makes a translation? > > if (exists $ref->{$new}) { > warn "Padded key $new already exists"; > } > else { > $ref->{$new} = delete $ref->{$_}; > } > } > } Nice! Thanks for the tips. -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]