# . . . . . - rest of the code # here, NAME is CHAR(16) -not so important, while DATA is BLOB field! $sql = "SELECT NAME, DATA FROM DOCUMENTS WHERE DOCNAME='$something'"; # $something was previously defined! $sth = $dbh->prepare($sql) or die "Preparing: ", $dbh->errstr; $sth->execute or die "Executing: ", $sth->errstr; $ii = 1; $name = ""; # fetching the content while (@row = $sth->fetchrow_array()) { foreach (@row) { if ($ii%2 == 1) { # so it is DOKUMENT's NAME! $name = $_; } else { # so, this is DATA! # opening FILE HANDLER for writing the content of the BLOB field open (F, ">./$name"); binmode F; # saving into the file "$name"! print F "$_"; close F; $name = ""; }; $ii++; }; }; $sth->finish; $dbh->commit or warn $dbh->errstr; $dbh->disconnect or warn $dbh->errstr; # . . . . . - rest of the code