$input = '$b'; @var = ('a','$b','$c','d','e','$f','g'); unless (grep /^$input$/, @var or $var eq "") { print "error"; }