$ditemid+0 works, so does int( $ditemid ). Perl will cast automatically, so we don't worry about when adding things, etc, but in this case we're storing in the database, and there's no guarantee that the caller will have sanitized the input (we do now but that could get overlooked in code changes in the future!), so it's better to be really safe just before we store it.