Do you know where your variables are? | |
PerlMonks |
Re: regex expression helpby ikegami (Patriarch) |
on Nov 08, 2005 at 19:36 UTC ( [id://506855]=note: print w/replies, xml ) | Need Help?? |
For the input you gave, it won't make a difference, but if $Y is a constant string, not a regexp, you should escape it, as follows:
I also removed the useless 'g' option and the useless 'next'. But if it's not a regexp, why use m// at all! index is much faster:
With a slight optimization:
If the $Y will always be at the end of $X, the following is even faster and more accurate:
I haven't solved the problem where $X is c:\path\ab.exe and $Y is b.exe. There are a couple of solutions, but I'll let you try to solve it before I say more.
In Section
Seekers of Perl Wisdom
|
|