There is no need to increment a counter to keep track of
how many elements are deleted from the array. You can simply
get the size before the deletion, and substract the size
afterwards to get the difference.
Here's how I would do it:
sub delete_field {
my $self = shift;
my $delete_field = shift;
my $before_deletion = @{$self->{_fields}};
@{$self->{_fields}} =
grep { $delete_field ne $_ }
@{$self->{_fields}};
return $before_deletion - @{$self->{_fields}};
}
You may also want to check out Removing certain elements from an array, which
has some neat idioms somewhat related.