use strict; use warnings; my %lookup = ( 1 => 567898, 2 => 543267, ); my @test = qw(0 a 2 1); for (@test) { print exists $lookup{$_} ? $lookup{$_} : $_, "\n"; } __END__ 0 a 543267 567898