in reply to Re: using an image in binary perl
in thread using an image in binary perl TK

NOP,
I Need to load it anyway , it must become part of my code.
I mean that when I'll activate the binary It
won't have to search for any file , all the data it needs
should be compiled inside it.
very simillar to .pm files

THANKS FOR YOUR TIME
michaelg

Replies are listed 'Best First'.
Re: Re: Re: using an image in binary perl
by bart (Canon) on Nov 16, 2003 at 17:50 UTC
    You could use Perl's built in UU-encoding, built into pack/unpack, using the "u*" template, to convert any binary string to a text string of limited line length.

    You can use the following code to load the file and generate the Perl code to set the image string, which you can then include in your script:

    { open IN, "tsl_logo1.gif"; binmode IN; local $/; print "\$image = unpack 'u*', <<'_END_';\n"; print pack "u*", <IN>; print "_END_\n"; }

    Of course, that requires that you can just set an image in a UI from a binary string, instead of loading it from a file. I don't know what module you're using for the UI, so you'll have to check that yourself.

Re: Re: Re: using an image in binary perl
by simonm (Vicar) on Nov 16, 2003 at 16:12 UTC

    The proper way of packing along extra files differs depending on how you're creating the binary.

    Please tell us what tools you are using to produce the executable -- perl2exe? PAR?