return $self->$sub(@_);
}
+sub call_sub_if {
+ my $self = shift;
+ my $sub = shift;
+ my $check = shift;
+
+ $check = $check->($self) if ref($check) eq 'CODE';
+
+ return $check ? $self->$sub(@_) : $self;
+}
+
1;
__END__
my $chart_id = $buchungsgruppe->call_sub(($is_sales ? "income" : "expense") . "_accno_id_${taxzone_id}");
+=item C<call_sub_if $name, $check, @args>
+
+Calls the sub C<$name> on C<$self> with the arguments C<@args> if
+C<$check> is trueish. If C<$check> is a code reference then it will be
+called with C<$self> as the only argument and its result determines
+whether or not C<$name> is called.
+
+Returns the sub's result if the check is positive and C<$self>
+otherwise.
+
=back
=head1 AUTHOR