if (defined($commitvalue) && ($commitvalue == 1)) { print "Yes, commit! Commitvalue = $commitvalue\n"; $self->committoDB; # <- HERE } elsif ($counter == $self->commit) { $self->committoDB; # <- and HERE! }