in reply to Re^2: extract pdf from blob
in thread extract pdf from blob
The chunks in the square brackets are the bits of Perl code that I can't specify because you didn't give enough clues.#!/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);
For the first one, you need to get access to your database. In the Perl community, it seems that the DBI package is the most popular (it's what I use). I don't know anything about DBISAM, so I don't know if there's a DBI driver module available for it. If not, then you could use the ODBC driver (again, that's what I usually use), providing you have an ODBC driver for your database.
For the second item (the decode function), I can't help you with that as you haven't told me anything about the encoding scheme. If you know the encoding scheme, look on CPAN for a module that will decode the appropriate scheme, and plug in the appropriate code.
In the final chunk, if you used DBI, you could use something like this:
Of course, there are now a few new blanks to fill in which you'll have to determine, because you didn't say.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];
--roboticus
|
|---|