I think you are looking at two different things here, firstly if you print @array as:
you will get the elements of @array separated by the value of $" (aka $LIST_SEPARATOR if using the English module). so you can do:print "@array";
will not output the spaces - of course in this simple case you can simply omit the double quotes and the items will not be separated, I am assuming you are interpolating into a larger quoted string.local $" = ''; print "@array";
If you want to remove any array elements that comprise only whitespace you can use grep :
You could also use map to strip leading or trailing whitespace from the elements:@array = grep !/^\s+$/, @array;
and so forth.@code = map { s/^\s+//; s/\s+$//; $_ } @array;
/J\
In reply to Re: remove whitespace from an array
by gellyfish
in thread remove whitespace from an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |