Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^3: alphabet counting

by sauoq (Abbot)
on Jun 02, 2012 at 14:19 UTC ( #974022=note: print w/replies, xml ) Need Help??

in reply to Re^2: alphabet counting
in thread alphabet counting

i have problem with hash printing !!!

You could guess that any such problems could be easily resolved... did you try something like this:

print "$k => $h{$k}\n" for my $k (sort keys %h);

"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re^4: alphabet counting
by Not_a_Number (Prior) on Jun 02, 2012 at 21:11 UTC


    my %h = ( a => 1, b => 2, c => 3 ); print "$k => $h{$k}\n" for my $k (sort keys %h);


    syntax error at D:\progs\perl\ line 5, near "$k (" Execution of D:\progs\perl\ aborted due to compilation errors.

    Maybe you meant something like:

    print "$_ => $h{$_}\n" for sort keys %h;

    Or the (no doubt) more newbie-friendly:

    for my $k ( sort keys %h ) { print "$k => $h{$k}\n"; };

      ++ seven hours and several upvotes later. It's amazing how few people are trying around here these days.

      "My two cents aren't worth a dime.";
        . It's amazing how few people are trying around here these days.

        S'always slow on Saturdays.

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974022]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-04-23 22:14 GMT
Find Nodes?
    Voting Booth?