#Loop through the records while (@row = $sth->fetchrow_array) { #Loop through binary data and write to a file at 10KB chunks. while(1) { $len = $sth->syb_ct_get_data(3, \$imgchunk, 10240); print "Size: $len\n"; # print "$imgchunk \n"; open FILE, "+>>something.pdf" or die $!; print FILE $imgchunk; close FILE; last if $len != 10240; }