in reply to Can I change the definition of '\s'?

As perlman:perlfaq4 says, is would be better to remove leading and trailing whitespace with two steps, not one:
for ($string) { s/^\s+//; s/\s+$//; }

So, I'd suggest doing it with two separate supstitutions and the custom-character-class-as-a-string that davorg and John M. Dlugosz suggested. HTH

--

There are 10 kinds of people -- those that understand binary, and those that don't.