in reply to Re^3: Passing input through a hash then displaying results
in thread Passing input through a hash then displaying results

How do I represent the values and keys in a loop or conditional statement?
  • Comment on Re^4: Passing input through a hash then displaying results

Replies are listed 'Best First'.
Re^5: Passing input through a hash then displaying results
by graq (Curate) on Jan 23, 2007 at 08:25 UTC
    How do I represent the values and keys in a loop or conditional statement?

    You gets the keys and values of a hash using keys and values.
    There is various documentation throughout the internet: keys and values.

    I'm not sure if map counts as a loop, but if it does, then this has hash values in a loop and a conditional (or two):

    sub get_grade { my $score = shift; my $grade = 'Ungraded'; $score = 0 unless $score =~ /^\d+$/; map { $grade = $grade_scores{$_} if $score > $_ } sort keys %grade_s +cores; $grade; }

    -=( Graq )=-