void rmsp(SV * sv) { char * end; int length; if( !SvPOK(sv) ) return; end = SvEND(sv); length = SvCUR(sv); end--; /* skip \0 */ while( *end == ' ' && length >=0 ) { end--; length--; } if( length >= 0 ) SvCUR_set(sv, length); }