http://www.perlmonks.org?node_id=834467


in reply to for loop error

You use foreach keys($xhash)

Either use $_ as the key to your hash in the loop or explicitly specify foreach my $k keys($xhash)

Replies are listed 'Best First'.
Re^2: for loop error
by almut (Canon) on Apr 13, 2010 at 11:37 UTC

    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.