#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect(...) or die $DBI::errstr; my $select = q~SELECT boot FROM infos~; my $sth = $dbh->prepare($select) or die $dbh->errstr(); $sth->execute(); my ($bin) = $sth->fetchrow_array(); my $target = '/path/to/target.file'; open(my $fh,'>',$target) or die $!; binmode $fh; print $fh $bin; close $fh or die $!;