while (my $row = $sth->fetchrow()) { #fetchrow_arrayref # Save blob data into this file: # print FILE $row; # if you are fetching an array reference with a single value: print FILE $row->[0]; }