I'm really sorry for the blunder salva. I was not passing the user name while creating the connection. Now SSH is working fine on both the machines.
After this worked, i realized the mistake that I was committing while using the earlier module (Net::SCP::Expect). Now the script is working with that module too. To simplify the explanation, in the first SCP, i needed to run the SCP as user A while in second SCP, which was on a different server, I needed a different user. However, in my script, I was using the same user A for performing SCP on both the machines and thatís why it wasnít working.
Your pointer helped me in realizing the blunder I was committing. Thanks a lot! :)