(my $user_agent = $ENV{USER_AGENT}) =~ s!!!; if (exists $user_agents->{$user_agent}) { # foo } else { # bar }