in reply to Re^4: How to open nested SSH connection using perl
in thread How to open nested SSH connection using perl

That means your version of the SSH client is too old and doesn't support the -W feature.

Your current solution is not very elegant because others may be able to use the tunnels you are creating to get to serverB without login into serverA first.