in reply to Re: Removing empty string elements from an Array
in thread Removing empty string elements from an Array
Aside from the issue of readability, which is obviously subjective, this solution will drop any occurences of '0' from the array. A more explicit check is necessary, as in the earlier grep solutions:
(Personally, I also prefer grep to solve this problem.)my @newArray; foreach my $element ( @array ) { push $element, @newArray if defined $element and $element ne ''; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Removing empty string elements from an Array
by traisjames (Initiate) on Apr 04, 2016 at 06:44 UTC |
In Section
Seekers of Perl Wisdom