http://www.perlmonks.org?node_id=800845

cthar has asked for the wisdom of the Perl Monks concerning the following question:

How do we add element to an array only if the element is non-empty? ie.... i have a list of element:

a b c d a a c d c
... etc so i want to add only a, b, c and d, ignoring the blank spaces. i tried:
unless($list eq " ") { push(@array, $list); }
what am i doing wrong? thanks.

Again... i dont want to store/add the repeated element.... ie my array will contain only a, b , c and d. Thanks.