in reply to Re: for loop error
in thread for loop error

I think the real problem here is the missing parens

foreach ( keys(%xhash) ) {

because of which Perl interprets keys as a variable name, and complains about the missing sigil...  —> use diagnostics;

Also, it should be %xhash, not $xhash.