use $variable=~s/^ *(.*) *$/\1/; In plain english: search for spaces at the beginning, then stuff in the middle, then spaces at the end, and replace the whole shibang with what was found in the middle (the stuff inside the ()). i didn't try it, so tell me if it doesn't work. -nat