As a part of my project, I need to ftp files to multiple destinations. Specifically, I need to query a table that contains details(host,port,user name, password etc) about destinations and I need to ftp a file to all those destinations. I will be using a perl script for ftp-ing files(a standard perl script that gets used in my project). I need a functionality that works like below.

Query : Select host,port,username,password from DESTINATION where type='ABC'
File to be FTP-ed : sendme.txt

1) take the 1st row of the query result.
2) ftp sendme.txt to the 1st destination.
3) take 2nd row of the query result.
4) ftp sendme.txt to the 2nd destination.
........ and so on.

Please do give me inputs on how I can go about doing this. Thank you so much for your help.

PS : If using FTP job of Pentaho would solve my problem, I am open to using that too.