I have to retrieve a result set and store the data in a file. I have a column in the database result. If the result is Y i want to store then data in one file and if the result is N I want to store it in another file. How can do this without replicating the select statement in Perl. I know I could use the sprintf but I am not sure how. Please advise.