@list = qw( this that other \w+\s\w+ ); $re = join '|', @list; $re = qr/$re/; print "Match\n" if 'foo bar' =~ m/$re/; #### $re = join '|', map{quotemeta} @list; #### my $re; my $str = '(foo'; eval {$re = qr/$str/}; if ( $@ ) { print "Oops $@\n"; } print "Still running.....$re\n"; $str = '/;print"You hacked me!";/'; eval {$re = qr/$str/}; if ( $@ ) { print "Oops $@\n"; } print "Still running.....$re\n"; $str = '/;print"You hacked me!\n";/'; eval "\$re = qr/$str/"; if ( $@ ) { print "Oops $@\n"; } print "Still running.....$re\n"; __DATA__ Oops Unmatched ( before HERE mark in regex m/( << HERE foo/ at C:\PROGRA~1\PERLBU~1\debug\test.pl line 5. Still running..... Still running.....(?-xism:/;print"You hacked me!";/) *****You hacked me! Still running.....(?-xism:)