in reply to Cannot open slave error.

It's impossible to determine from what you've written here.

First, you don't specify the error you're getting. Second, I can't tell what you may have clobbered when you turned the code into pseudo-code. As it stands, nothing will execute because you set $option to 0, and then check for values of 1 and 2. It wouldn't matter anyway, because your two subroutines appear to be identical.

Take a look at Before You Post ... and How (Not) To Ask A Question for points on asking questions effectively, then post some more info.