I would use uuencode/uudecode. Don't forget the single-quotes around the here-doc label, or else it will try to interpolate variables in the uuencoding.
#!/usr/bin/perl print "Content-type: image/gif\n\n"; print uudecode(<<'END_OF_GIF'); begin 664 test.gif M1TE&.#EA*0`4`.<``/______S/__F?__9O__,___`/_,___,S/_,F?_,9O_, M,__,`/^9__^9S/^9F?^99O^9,_^9`/]F__]FS/]FF?]F9O]F,_]F`/\S__\S MS/\SF?\S9O\S,_\S`/\`__\`S/\`F?\`9O\`,_\``,S__\S_S,S_F<S_9LS_ M,\S_`,S,_\S,S,S,F<S,9LS,,\S,`,R9_\R9S,R9F<R99LR9,\R9`,QF_\QF MS,QFF<QF9LQF,\QF`,PS_\PSS,PSF<PS9LPS,\PS`,P`_\P`S,P`F<P`9LP` M,\P``)G__YG_S)G_F9G_9IG_,YG_`)G,_YG,S)G,F9G,9IG,,YG,`)F9_YF9 MS)F9F9F99IF9,YF9`)EF_YEFS)EFF9EF9IEF,YEF`)DS_YDSS)DSF9DS9IDS M,YDS`)D`_YD`S)D`F9D`9ID`,YD``&;__V;_S&;_F6;_9F;_,V;_`&;,_V;, MS&;,F6;,9F;,,V;,`&:9_V:9S&:9F6:99F:9,V:9`&9F_V9FS&9FF69F9F9F M,V9F`&8S_V8SS&8SF68S9F8S,V8S`&8`_V8`S&8`F68`9F8`,V8``#/__S/_ MS#/_F3/_9C/_,S/_`#/,_S/,S#/,F3/,9C/,,S/,`#.9_S.9S#.9F3.99C.9 M,S.9`#-F_S-FS#-FF3-F9C-F,S-F`#,S_S,SS#,SF3,S9C,S,S,S`#,`_S,` MS#,`F3,`9C,`,S,```#__P#_S`#_F0#_9@#_,P#_``#,_P#,S`#,F0#,9@#, M,P#,``"9_P"9S`"9F0"99@"9,P"9``!F_P!FS`!FF0!F9@!F,P!F```S_P`S MS``SF0`S9@`S,P`S````_P``S```F0``9@``,P```/__________________ M____________________________________________________________ M____________________________________________________________ M_____________________R'^#DUA9&4@=VET:"!'24U0`"'Y!`$*``$`+``` M```I`!0`0`B9`*\)'$BPH,&#"`T"6,BPX<)K``A&A$AQHL.+`B]JW,B18\:" M%CN*;$8M`00(%B"$%,FRI46$+C>6/&G!`K67'U?&;$BM9P(%"6YF9`FQ(<6A M+9%Z'!@1YT.=#I7NG/JP*-6K4J]J;/:3IE"K6F665'!2`52-3"L6S0D68]NP =2=^Z33NQ8MRD3=D.M8M6+MR.6?\"3DBX<.&``#L` ` end END_OF_GIF # uudecode subroutine shamelessly copied from elsewhere on the net sub uudecode { my $in = shift; my $out = ""; foreach( split(/\n/,$in) ) { $_ .= "\n"; last if /^end/; next if /[a-z]/; next unless int((((ord() - 32) & 077) + 2) / 3) == int(length( +) / 4); $out .= unpack("u",$_); } return $out; }

In reply to RE: Files, unpack and text values by httptech
in thread Files, unpack and text values by BBQ

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.