in reply to Re: How to delete trailing spaces from array elements?
in thread How to delete trailing spaces from array elements?

The asignment is unnecssary since you've already modified @arr1 by modifying $_.
use List::MoreUtils qw( apply ); @array = apply { s/\s+\z// } @array;

or

map { s/\s+\z// } @array;

or

s/\s+\z// for @array;

Replies are listed 'Best First'.
Re^3: How to delete trailing spaces from array elements?
by mart (Initiate) on Jul 31, 2007 at 16:54 UTC

    if you don't want to dig into regular expressions (that funny /\s+$//gms stuff) yourself, you might try this approach:

    use Text::Trim; my @strings2trim = ("yo ", " boo"); trim(@strings2trim);