I have a perl script which is called by another application in a parallel mode.
Most of the code in this script runs fine but at the end this perl script uses NET:MTP package to send mails and this part of the code is not behaving correctly . some of the processes miss this function and do not send emails.

Can anyone suggest how do i make this part of the code multi process safe ,i.e how should i restrict that only one process executes this function ?