$dbh->{LongReadLen} = '20000'; opendir(DIR, "/RAWdata") || die "Cannot open gif:$!\n"; my @filenames = grep !/^\./, readdir(DIR); close(DIR); my $title; # #Select out RAW's based on their filename - R_NAME # foreach my $title (@filenames) { my $sth = $dbh->prepare("SELECT R_RAW from RAH where R_NAME='$title'"); $sth->execute(); # #Put selected RAW into an array, write it to a file using the filename you #got from the RAWdata directory. # my @jpg = $sth->fetchrow_array(); open(FILE, ">$title") || die "Cannot open file for writing: $!\n"; print FILE @jpg; close(FILE); $sth->finish();