in reply to without looping, check if $var is found in @list
Obviously you could get rid of @list entirely above.#!/usr/local/bin/perl use strict; use warnings; my @list = qw(frog turtle tadpole); my $var = "turtle"; my %check_list; @check_list{ @list } = (); if( exists $check_list{ $var } ){ print "found $var!\n"; }
|
|---|