in reply to problem with hash keys

Actually, the fact that you get keys from #1 and #2 in correct order is pure coincidence -- a hash does not remember sequence of assignements. If you want to keep that information you'll have to create an array for keeping key order.

Another option is to use the sort function -- in your examples you use alphabetical order, so if that is what you want you can use something like this:

foreach my $k ( sort keys %GRAMMAR ) { print "$k\n"; }


-mk