\s matches newlines too, meaning that your pattern will remove empty lines, not just trim them. An alternative is
s/^[^\S\n]+//gm; s/[^\S\n]+$//gm;
ihb
See perltoc if you don't know which perldoc to read!
In reply to Re^2: trim leading & trailing whitespace
by ihb
in thread trim leading & trailing whitespace
by ady
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |