This is how you can do it in bash without being prompted to do it again.
Code:
passwd --stdin < passwordfile username
e.g.:
Code:
passwd --stdin < pswdfile thomas
You would have to create a temporary file called pswdfile and the remove it.
Since you are writing this in perl you would have to make those lines into system calls.
BW