reg accepting password

Hi,
I want to login to many systems and password should be taken automatically from a file(login is working but password is not accepting). Any help on this is appreciable .

My code.

for i in `cat /tmp/tes ` ====>tes file contain list of hosts
> do ssh $i
> perl prog.pl
> done

cat prog.pl =====> perl coding file
#!/usr/bin/perl
open(MYFILE,'abc.txt'); =====>abc.txt contain password which is same for all the hosts
print ("The value ");
while($value=<MYFILE>)
{
print ($value); ========> password value not printing after login
}

Would using passwordless SSH be a simpler solution to what you are trying to achieve?