not sure if this is the source of your problem, but the @ symbol is being interpolated as an array because you have it inside a double-quoted string, use single-quotes:
$ssh = 'ssh username@host';
also, when you use exec in perl it does not return back to the perl script, although I am not sure what happens when you run it in a forked process. Try system() or qx//. qx// returns process output back, system() does not. Look them up in the perl documentation.
Next time put Perl in your subject line if that is what you are using.