Login to a remote solaris machine as superuser through perl

I am trying to write a perl script that will do remote machine.
I have done user loging using simple command;

$telnet->login('test', 'test123');

But now I want to do root login or superuser login. So I tried the superuser command,

$telnet->cmd("su");

But I am not able to send the password , like,

$telnet->put("Password");

neither the command returns any text for prompt. How can I do this?

Same thing I am also trying to login to a remote mysql server, but it is not working.

Any suggestions ....