in reply to splitting a line by user-defined separators
Build your own regex out of your user's input.
my @match = qw(; : -); my $match = join('|', map { "\Q$_" } @match); if ('random-text' =~ /$match/) { print "yep\n"; } else { print "nope\n"; }
Note the use of \Q in case your users input regex metacharacters. \Q escapes them so they aren't treated as metacharacters.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|