my %h = ( 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four' ); $s = $h{$n} // 'ETOOBIG'; # needs perl 5.10 #$s = $h{$n} || 'ETOOBIG'; # works for any perl print "$n : $s\n"