in reply to Can't call method "prepare" on an undefined value

As the message says:

Can't call method "prepare" on an undefined value at mwslib.pl line xxx.

$mwsdbh must not be visible from within the scope of your subroutine, or not initialized by the time your subroutine is invoked. Another option is that $mwsdbh is not the correct spelling.

Good luck...