in reply to Laziness is one of the three virtues!
in thread the end of a word

That's a common misconception regarding \w and \W. The "word" characters (depending upon locale) are typically letters, underscores, and digits. Thus, the \W will not remove underscores or digits from the end.

$ perl -e '$_="foobar_";s/[^a-zA-Z]+$//;print' foobar $ perl -e '$_="foobar_";s/\W+$//;print' foobar_ $ perl -e '$_="foobar9";s/\W+$//;print' foobar9

Update: I pointed out a bug in your code only to realize a bug in mine :) My first example doesn't respect locale settings. I should be using POSIX character classes.

$ perl -e '$_="foobar_";s/[[:^alpha:]]+$//;print' foobar

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.