$input = '...'; # input from user $value = '...'; # String I want to test to see if $input matches # escape s/delimiter/ $input =~ s|/|\/|gs; # strip new lines - not expected in input anyway $input =~ s/\n//gs; my $match; eval q{ $value =~ /($input)/; # try match $match = $1; # assign here because of local scope? }; if ($@ ne '') { # error because invalid reg exp sent } else { if ($match) { # regexp matched } else { # reg exp not matched } }