Hi again, I thank you all for your comments. By experience from other forums I somehow expected nothing more than a "RTFM, dork!". I'm very happy that didn't happen here. :-)

Every time I have to try something with perl I have to read the docs, most time the perlre. I read that back and forth, from left to right, but didn't find the answer to my problem.

And yes, m/(.*?)fish(.*)/ was exactly what I was looking for. I just overlooked two things:

- the possibility to tie the "?" to something that's a match pattern itself
- the idea of "greediness" in matches.
Never, not in my darkest dreams, would I have come up with a solution like that. In my opinion a pattern has to find the leftmost match, period. But who am I to judge this - Perl is like that, go with it.

And, as the perldocs say somewhere at the beginning: There's always more than one way to reach your goal. So I will look into the split function also, perhaps that's an alternative to my problem.

So, to come to and end, I hope I don't have to ask a lot of questions here - but of course I will if there's another problem. ;-)

Thanks again and have a nice day all,
Faltblatt


In reply to Re: match last element instead of first?? by Anonymous Monk
in thread match last element instead of first?? by Anonymous Monk

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.