in reply to Array Cleaning
I actually used something like this in a module I'm writing. I hope it's of some use to you. YMMV.my $splice_index = 0; my @splice_list; for (@clean) { if (length($_) == 0) { #zero - length string push(@splice_list,$splice_index); $splice_index++; next; } $splice_index++; } #now we have our splice list built up. so, we take care of the element +s that need to go. while (@splice_list) { my $index = pop(@splice_list); splice(@clean,$index,1); } print "$_\n" for @clean; #should produce the correct results @clean = map {s/\s+//g; $_ } @clean; #i try to avoid map in void conte +xt, except for in my sig ^_~ print "$_\t" for @clean; print "\n";
|
|---|