eval q{ if ($value =~ /($input)/) { # try match $match = $1; # assign here because of local scope? } };