in reply to Removing null values from within an array
my @original = ("", undef, "perl hungry", "", "twenty"); my @original_kept; foreach(@original) { my $what_we_removed = shift(@original); # take our first item off and +keep it if (defined $what_we_removed && $what_we_removed ne "") { push(@original_kept, "$what_we_removed"); } } print join("\n", @orignal_kept);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Removing null values from within an array
by TomDLux (Vicar) on Mar 07, 2004 at 03:45 UTC |