in reply to printing Hash

You put that inside out, you're testing $_ before you have a value for it. Properly ordered, with the for and the if swapped, the code becomes:
for my $key (keys %hashs) { for (keys %{$hashs{$key}}) { print "$key - $hashs{$key}{$_} -> $_\n" if $hashs{$key}{$_} > 1; } }

Replies are listed 'Best First'.
Re^2: printing Hash
by perlbeginner10 (Acolyte) on Mar 25, 2006 at 16:51 UTC
    Hi
    In the code that you suggested, I HAVE to include the : for keys %{$mappings{$key}}; at the end of print statement.
    I did this:
    for my $key (keys %mappings) { print "$key - $mappings{$key}{$_} -> $_\n" for keys %{$ma +ppings{$key}} if ($mappings{$key}{$_} > 1); }
    But the code still doesn't work.
    The error message is:
    syntax error at test.pl line 33, near "} if"

    Thanks
      You can't put two "modifiers" in a single statement. That's what you're trying to do, and that's what perlsyn says you can't do — unfortunately.
      Any simple statement may optionally be followed by a SINGLE modifier, just before the terminating semicolon (or block ending).
      I didn't even need to stress the word "single" myself, it's written like that in the docs.
        Thanks man,
        Is it possible to put if statement somewhere before or after the print statement?

        Thanks