in reply to work with url
Actually, maybe you can do this within a spreadsheet, by defining the database-query as a data source. In some cases, the spreadsheet will issue the repeated queries for you in order to produce the results you need, as it resolves the spreadsheet. Writing a short function in a built-in scripting language (e.g. Visual Basic) is also a possibility. Carefully review the database-querying capabilities (and associated examples) in the spreadsheet and/or data analysis tools that you are using. Perhaps the use of Perl (or any outside language/script), in this case, can be avoided.