Check whether you have established the connection with the remote server by checking the return value of each the $telnet -> ... commands.
Also, in your code, you have used single quotes as in
print $telnet->cmd( 'dir' ); , but in your problem statement, you mention backticks "`".
You might also want to have a look at this node. Perform a Super Search, where you might get more useful hints.