in reply to Efficient trimming of trailing whitespace from array elements?
With a subtle difference from suggestions made by others, I suggest that the removal of whitespace from the end of all array elements should be accomplished using the code:
s/\s+\z// for @ARRAY;I choose to use '\s+\z' instead of '\s+$' as '\s+$' means "all whitespace up to the end-of-string but not including a possible newline at the end-of-string." '\s+$' works in that \s+ is greedy and grabs the newline, however, the statement is not as clear. '\s+\z' means "all whitespace up to the end-of-string".
|
|---|