in reply to Trimming whitespaces methods
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.
|
---|