Well, here is another:
the strip method of string removes whitespace from both ends.
Python has lstrip and rstrip as well, to do each end on its own.

http://www.python.org/doc/current/lib/module-string.html

but that is not too bad either:  sub!(/\s+$/,'') will give rstrip.

	Hugh
	hgs / dmu.ac.uk