The best way is:
s/^\s+//, s/\s+$// for @array; [download]
In reply to Re: Trimming whitespaces methods by jwkrahn in thread Trimming whitespaces methods by harishnuti