use DBI; use strict; my $dbh = DBI->connect("DBI:Oracle:host=172.16.21.16;sid=xxxxxx", 'xxxxx', 'xxxxx') or die "Connecting : $DBI::errstr\n"; $dbh->{LongReadLen} = 512 * 1024; my $sth = $dbh->prepare("Select TITLE, HEX_PIC from pics"); $sth->execute(); (my $name, my $image) = $sth->fetchrow_array; my $output = pack("H*", $image); print "Content-type: image/gif\n\n"; print $output; open(FH, ">outfile.gif"); binmode(FH); undef $/; print FH pack("H*",$image); close FH;