PERL Black Book mentions you can delete $array[index], it doesn't say there are limitations or anything. It makes it sound like you can delete ANY element by doing it like this but someone in the room said otherwise. Can someone explain this to me?
I have an array with blank values and I cannot get rid of them with grep, delete splice. To see what was actually contained that was causing problems, I used print "This is what we found: \"\""; and the result comes back literally "This is what we found: "". So it's empty and/or undefined.
Things I have tried:
@n = grep $_, @n;
@n = grep defined, @n;
@n = grep defined and length, @n;
for(my $count = 0; $count < @myarray; ) { unless(defined $myarray[$count]) { splice @myarray, $count, 1; } else{ $count++ } }
my $count = -1; foreach(@myarray) { $count++; if (!defined $_) { splice(@myarray,$count); #delete $myarray[$count]; } } No matter which of these I use, when I print out the array I get a han +dful of "Use of uninitialized value at line 55". Anyone have any sug +gestions as to why these little buggers won't go away?
In reply to Removing null values from within an array by coldfingertips
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |