$string =~ s/^\s+//; # ltrim
$string =~ s/\s+$//; # rtrim
$string =~ s/^\s+|\s+$//g; # trim
Regards, -- Hauke D | [reply] [Watch: Dir/Any] [d/l] |
| [reply] [Watch: Dir/Any] |
Hi Marshall,
You're right, I didn't mention that because of what the FAQ says: "That might not matter to you, though". That attitude reminds me of the last time I read the Camel, I realized that for a large part of the book no mention is made of performance at all. I found that quite enlightening, along the lines of "until performance becomes an issue, don't worry about it" (a friendlier version of "premature optimization is the root of all evil"). I'm not advocating totally ignoring performance, but instead for worrying less when one can allow oneself to. Personally, I prefer the one-regex solution for its brevity, and so far I've usually been in a position where that performance difference doesn't matter. Of course, that can be a luxury, so thank you for mentioning the issue in case it does matter to the OP :-)
Regards, -- Hauke D
| [reply] [Watch: Dir/Any] |