$items = { a => 1, b => 2, c => 3, }; if ( exists $items->{ $variable } ) { # . . . }