If I'm reading this correctly, you are trying to match a word at the end of a string.  
If that's the case then move the word boundary to the end of your match.

print $& ."\n" if (/eat\b/);
print $& ."\n" if (/gre\b/);

Reading from the "Learning Perl 3rd" Edition on page 108:

"The \b anchor matches at the start or end of a group of \w characters".

\b at the beginning of the word will match only the beginning and no ending characters.

If you are looking for more then perhaps a nonword-boundary anchor is what you are 
looking for?

>From Page 109 it reads:

"The nonword-boundary anchor is \B; it matches at any point where \b would not match.  
/\bsearch\B/ will match searches but not researching".

Hope this helps.

> friends,
> ************************
> script :
> 
> $_='as great as perl';
> print $& ."\n" if (/\beat/);
> print $& ."\n" if (/\bgre/);
> 
> output :
> gre
> ***********************
> Why 'boundary' assertion does not match in end of word , but only the start of 
> word?
> 
> thanks,
> Jay
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to