in reply to Re^2: array with s///g command
in thread array with s///g command

You can simply join the statements
my @array2 = @array1; s/\s+//g for (@array2);
into one:
tr/ //d for my @array2 = @array1;
The tr/// here only treats blanks instead of general white space, but that's easily changed if necessary.

Anno