|XP is just a number|
Re: How to call a function on each item after a split?by kcott (Canon)
|on Oct 09, 2012 at 09:02 UTC||Need Help??|
I see you have a lot of responses already. Here's my take on this.
You can trim the data by capturing everything that isn't leading or trailing whitespace with this regular expression:
You can use that directly inside a map like this:
You can use it inside a subroutine called from map like this:
It's good that you've tried a variety of cases with whitespace in different positions in your test input $str. What you don't have is leading whitespace at the start of $str or trailing whitespace (following non-whitespace) at the end of $str.
Here's my tests using both of the options I presented with some additional test data.