Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

G'day, monks. I've been playing with SQLite alot lately, and I'm trying to find a way to add binary attachments to the database. The SQLite docs recommend Base64 encoding, so I thought I'd experiment with that a bit.

Here's my program to encode files in Base64:

#! /usr/bin/perl use strict; use MIME::Base64 qw( encode_base64 ); use IO::All; encode_base64( io( $ARGV[0] )->slurp ) > io( $ARGV[1] ); __END__

And the matching decode program:

#! /usr/bin/perl use strict; use MIME::Base64 qw( decode_base64 ); use IO::All; decode_base64( io( $ARGV[0] )->slurp ) > io( $ARGV[1] ); __END__

Here's what I tried to test it:

Z:\>perl yearsinservice.pdf yis.b64 Z:\>perl yis.b64 yis.pdf

When I try to open yis.pdf with Acrobat Reader, it says there's an error in the file. The original PDF works fine. Any suggestions?

UPDATE: I moved these PDFs to my Linux box and used hexdump -C to look at them - it looks like an endline issue (yis.pdf has Windows-style endlines). I tried adding local $/ = "\n"; to each file, but that didn't seem to help.

Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

In reply to Problem Encoding/Decoding PDF with MIME::Base64 by DamnDirtyApe

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-11-28 06:44 GMT
Find Nodes?
    Voting Booth?

    No recent polls found