sub to_int_or_zero { my $value = shift; $value =~ s/,/\./; if (defined($value) && $value =~ m/^\d+$/) { return $value; } else { return 0; } }