in reply to Re: how can i split a string to an array and convert it into regular expression
in thread how can i split a string to an array and convert it into regular expression

You forgot to strip the line endings and you needlessly invoke the Perl parser and compiler in addition to the regex parser and compiler when only the latter is needed.

# If we are reading in regexs. chomp( my @arry = <> ); my $pattern = join('|', @arry); my $regex = qr/$pattern/;
# If we are reading in text strings. chomp( my @arry = <> ); my $pattern = join('|', map quotemeta, @arry); my $regex = qr/$pattern/;

Replies are listed 'Best First'.
Re^3: how can i split a string to an array and convert it into regular expression
by plobsing (Friar) on Dec 08, 2007 at 19:36 UTC
    I thought qr// was a compile time thing. I stand corrected.
    Thank you.