m/(.*)fish/ makes perl go all the way to the end of the string and then back up to find fish...
m/^(.*?)fish/ tells perl to match as little as possible while still finding fish afterwards. It will only match zero characters though, unless you tell it to start from the beginning.
It's all explained rather well in perlre. I read that every year or so still and I've been at this quite a while. I also recommend reading perldata and perlref on a semi-regular basis.
-Paul
In reply to Re: match last element instead of first??
by jettero
in thread match last element instead of first??
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |