Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Removing empty string elements from an Array

by chipmunk (Parson)
on Feb 03, 2002 at 19:37 UTC ( #143094=note: print w/replies, xml ) Need Help??


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:
my @newArray; foreach my $element ( @array ) { push $element, @newArray if defined $element and $element ne ''; }
(Personally, I also prefer grep to solve this problem.)

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
    Forgive a noob, but shouldn't
    push $element, @newArray
    be
    push @newArray, $element

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143094]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2016-12-04 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (63 votes). Check out past polls.