in reply to Tutelage, part two

Try something like this:

my $top_X = 10; foreach $key (sort { $hash{$a} <=> $hash{$b} } keys %hash) { print "$key\t\t= $hash{$key}\n"; last if --$top_X <= 0; }
--
3dan

Replies are listed 'Best First'.
Re: Re: Tutelage, part two
by tilly (Archbishop) on Jan 04, 2004 at 23:22 UTC
    Style note.

    I would take the opportunity to throw my in front of $key and explain how strict.pm could be used to catch potential typos. You could also mention that it is important to indent consistently (as you did in your snippet).

      Well.... I think this sort of goes back to the answering the bigger question question. I know that you said over there that you are the 'answer the bigger question' type, so I suppose your comment here is in character. But I think 'just answering the question' is okay too, and that's what I did here - the OP was not looking for style points, and even mentioned that s/he knows that s/he should be using strict, etc. So I chose to simply answer the question that was asked...

      --
      3dan