Tova Yaron <[EMAIL PROTECTED]> wrote: > Trying to remove from array blank lines, its look like > splice get confuse with the array size after removing the > blank entry. Or maybe I'm getting confuse..
> my ($str0, $str1, $str2, $str3, $str4, $str5, $str6, $str7, $str8, > $str9,) > = > ( > "000000000000000000000000000000000", > "111111111111111111111111111111111", > "222222222222222222222222222222222", > "333333333333333333333333333333333", > "444444444444444444444444444444444", > "", > "", > "", > "", > "999999999999999999999999999999999", > ); > > my $ref_array = [ $str0, $str1, $str2, $str3, $str4, $str5, > $str6, $str7, $str8, $str9,]; You can also just say: my $ref_array = [ "000000000000000000000000000000000", "111111111111111111111111111111111", "222222222222222222222222222222222", "333333333333333333333333333333333", "444444444444444444444444444444444", "", "", "", "", "999999999999999999999999999999999", ]; > foreach my $indx (0..$#$ref_array) { > if ($ref_array->[$indx] =~ /^$/) { > splice (@$ref_array, $indx, 1); > } > } One possibility that would work is to use $ref_array = [ grep /^.+$/, @$ref_array ]; i.e. make a new array from all of the non-blank lines in the old array. If you really need to do this in place due to memory constraints, I would advise to run the iteration from back to front, i.e. for( my $i = $#$ref_array; $i >= 0; $i-- ){ splice(@$ref_array, $i, 1) if $ref_array->[$i] eq ''; } > foreach my $indx (0..$#$ref_array) { > print $ref_array->[$indx] . "\n"; > } better: foreach my $line (@$ref_array){ print "$line\n"; } Don't use array indices if you don't have to. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>