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


In reply to Many birds, single cage... by monsieur_champs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.