#!/usr/bin/perl -w use strict; use warnings; [code to open database] sub decode { my $encoded_data = shift; [code to decode $encoded_data to $decoded_data] return $decoded_data; } my $blob; [code to get column from database and put into $blob] my $pdf = &decode($blob); open(OUT_PDF, ">DOCUMENT.PDF") or die "Can't open file!"; print OUT_PDF $pdf; close(OUT_PDF); #### my $STH = $DBH->execute("SELECT [column] " . "FROM [table] " . "WHERE [condition]") or die "WTF? I can't find what you're looking for!"; my $array_ref = $STH->fetchrow_arrayref; $blob = $array_ref->[0];