Yes, you would probably do it similarly to the snippet you posted.

Here's a simple script that converts a file to a hex encoding:

#!/usr/local/bin/perl -w # convert binary file to hex use strict; @ARGV or die "Usage: $0 <filename>\n"; my $file = shift; open(FH, $file) or die "Can't open $file: $!\n"; binmode(FH); my $buf; while (read(FH, $buf, 32)) { # 32 bytes fit nicely on one line when hex-encoded print unpack('H*', $buf), "\n"; } __END__
And here's a script that converts a hex encoding back to the original data:
#!/usr/local/bin/perl -w use strict; $| = 1; while (<DATA>) { chomp; print pack('H*', $_); } __END__ 23212f7573722f6c6f63616c2f62696e2f7065726c202d770a0a2320636f6e76 6572742062696e6172792066696c6520746f206865780a0a7573652073747269 63743b0a0a4041524756206f7220646965202255736167653a202430203c6669 6c656e616d653e5c6e223b0a0a6d79202466696c65203d2073686966743b0a0a 6f70656e2846482c202466696c6529206f7220646965202243616e2774206f70 656e202466696c653a2024215c6e223b0a62696e6d6f6465284648293b0a0a6d 7920246275663b0a0a7768696c652028726561642846482c20246275662c2033 322929207b0a20207072696e7420756e7061636b2827482a272c202462756629 2c20225c6e223b0a7d0a
Of course, you could store the encoded gif in your script however you wish; a here doc would be an excellent way to do it.

In reply to Re: Embed GIF in perl source? by chipmunk
in thread Embed GIF in perl source? by epoptai

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.