#!/usr/bin/perl use warnings; use strict; use DBIx::Simple; my $db = DBIx::Simple->connect('dbi:SQLite:dbname=mydatabase.db') or die DBIx::Simple->error; #switch to 3 arg form, no advantage here but its a good habit ;) open (WEBPAGESFORALL, "<", "webpages.txt") || die "couldn't open the file!"; my @webpages = ; close(WEBPAGESFORALL); #remove trailing newlines chomp(@webpages); my @webpages_for_files; #print out the id's of the pages we want, seperated by commas print join(",", @webpages); #loop over the indexs we just grabbed from the file for (@webpages) { #push this page onto our list of saved pages. push @webpages_for_files, $db->query("SELECT webpage FROM webpages_data WHERE id = ?", $_)->list; #change the query to use place holders } print join(",", @webpages_for_files); #three arg form open (WEBPAGES_OUT,">", "giveit.txt") || die "couldn't open the file!"; foreach my $webp (@webpages_for_files) { print $webp ."\n"; } close(WEBPAGES_OUT);