in reply to remove whitespace from an array

There is no white space "stored" in @array. You're surely interpolating like thus: "@array". In which case, just... don't! Or else read up about $" in perldoc perlvar.