in reply to match the name

I think that you are looking for \b - word boundary.
m/ \b ap \b /xi;