#!/usr/bin/perl -w use strict; my %hash = ('1' => 'cat', '3'=> 'mouse', '5'=>'whale' ); my $elem = 2; if (defined($hash{2})) {print $hash{2}} else { print $hash{$elem+1}}; 1;