Use map with captures.
@array = map { m{ \s* # skip leading whitespace ( # then capture .* # the longest possible substring \S # that ends with a visible character ) }x } @array;
This loses any array elements that contained nothing but whitespace. If you want to retain these elements as empty strings, insert |$ in your capture.
In reply to Re: Trimming whitespaces methods
by Narveson
in thread Trimming whitespaces methods
by harishnuti
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |