in reply to Re: RegEx needed
in thread Efficient trimming of trailing whitespace from array elements?

Did you mean to make a copy? Just trimming it is better done by a for loop: s/\s+$// for @data;. That fixes the existing array in place and would prevent such abortions as @data = map { s/\s+$//; $_ } @data which are all too likely given your original suggestion.


Fun Fun Fun in the Fluffy Chair

Replies are listed 'Best First'.
Re: Re^2: RegEx needed
by gjb (Vicar) on Dec 31, 2002 at 16:14 UTC

    If I'd suggested a for someone would have pointed out it's not Perlish ;-) Yes, I'm aware I'm making a copy. If one is concerned about performance though, it would be better to initialize the array with data not containing the trailing whitespace in the first place rather than having to fix it afterwards.

    Just my 2 cents, -gjb-