monsieur_champs has asked for the wisdom of the Perl Monks concerning the following question:
Fellows
I was trying to capture some different patterns using some large and weird regular expressions, and came across a funny problem. I need to capture a single piece of the code to a variable, but I have a lot of capture-enabled parentesis across the entire regular expression. So I tryied something like this:
my ( $piece ) = $strange_thing =~ m/($large)|$wei($rd)|($stra)$nge/;
I know for sure that when something matches, I will get it on the ${0} - ${\d+} variables, but what is happen is: when things matches with ($large), all goes fine, and $piece contains what I need; but when $strange_thing matches any other pattern, $piece ends with nothing inside. I'm doing something really stupid, I know, but I can't see what. How can I use the same cage to capture many different birds, one at a time?
Thank you all and may the gods bless you all.
"In few words, translating PerlMonks documentation and best articles to other languages is like building a bridge to join other Perl communities into PerlMonks family. This makes the family bigger, the knowledge greather, the parties better and the life easier." -- monsieur_champs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Many birds, single cage...
by Enlil (Parson) on Dec 09, 2003 at 20:34 UTC | |
by monsieur_champs (Curate) on Dec 09, 2003 at 21:32 UTC | |
by duff (Parson) on Dec 09, 2003 at 20:39 UTC | |
|
Re: Many birds, single cage...
by BrowserUk (Patriarch) on Dec 09, 2003 at 22:02 UTC | |
|
Re: Many birds, single cage...
by duff (Parson) on Dec 09, 2003 at 20:35 UTC | |
by Enlil (Parson) on Dec 09, 2003 at 21:41 UTC | |
by monsieur_champs (Curate) on Dec 09, 2003 at 21:28 UTC | |
by mr_mischief (Monsignor) on Dec 09, 2003 at 22:42 UTC | |
by monsieur_champs (Curate) on Dec 10, 2003 at 14:09 UTC | |
by mr_mischief (Monsignor) on Dec 10, 2003 at 14:51 UTC | |
| |
|
Re: Many birds, single cage...
by delirium (Chaplain) on Dec 09, 2003 at 20:44 UTC |