in reply to Working of new subroutine
What parts do you have problems with?
Also, the modules are not ComPort.pm and SerialPort.pm but likely Win32::SerialPort.