my $delim = '([{<';
my $prefix = qr{[^$delim]*};
As a general practice, I find it's much safer to interpolate strings like $delim into regexes using \Q \E metaquote escapes:
my $delim = '([{<';
my $prefix = qr{[^\Q$delim\E]*};
Of course, one could metaquote the string variable upon definition:
my $delim = quotemeta '([{<';
but that might screw up subsequent use of the string; e.g., its use in something like
my @parts = extract_bracketed($string, $delim, $prefix);
might become problematic.
Give a man a fish: <%-{-{-{-<
In reply to Re^2: bracket processing
by AnomalousMonk
in thread bracket processing
by rajaman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |