gaal has asked for the wisdom of the Perl Monks concerning the following question:
I know how to do all these:
# 1. my $any = qr/one|two|three/; # 2. my $one = qr/one/; my $two = qr/two/; my $three = qr/three/; my $any = qr/$one|$two|$three/; # 3. my @pats = qr/one/, qr/two/, qr/three/; my $any = qr/$pat[0]|$pat[1]|$pat[2]/; # ick
But I want:
my @pats = map qr/$_/, @some_input; my $any = ??? # no resort to explicit indices
Also, in my code the separate patterns are compiled much before the disjunction, so this is not what I'm looking for:
my $joined = join ")|(?:", @some_input; my $any = qr/(?:$joined)/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Programmatic regex disjunction
by Aristotle (Chancellor) on Nov 21, 2005 at 17:11 UTC | |
by Roy Johnson (Monsignor) on Nov 21, 2005 at 17:31 UTC | |
by ysth (Canon) on Nov 22, 2005 at 04:14 UTC | |
by Aristotle (Chancellor) on Nov 22, 2005 at 08:49 UTC | |
by gaal (Parson) on Nov 21, 2005 at 17:20 UTC | |
|
Re: Programmatic regex disjunction
by Tanktalus (Canon) on Nov 21, 2005 at 17:09 UTC | |
by gaal (Parson) on Nov 21, 2005 at 17:12 UTC | |
|
Re: Programmatic regex disjunction
by Zaxo (Archbishop) on Nov 22, 2005 at 05:28 UTC | |
|
Re: Programmatic regex disjunction
by diotalevi (Canon) on Nov 21, 2005 at 19:24 UTC | |
|
Re: Programmatic regex disjunction
by ysth (Canon) on Nov 22, 2005 at 04:31 UTC | |
by Aristotle (Chancellor) on Nov 22, 2005 at 09:01 UTC | |
|
Re: Programmatic regex disjunction
by NetWallah (Canon) on Nov 22, 2005 at 01:51 UTC | |
by gaal (Parson) on Nov 22, 2005 at 07:17 UTC |