Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All

I am using pack to encode a small section of source code I have written but it does not seem to function on other servers, is it not portable after doing this?

What I have done is to put the packed code after __END__ then call it with data, on my server it works fine but on others it executes but produces no output.

.Any suggestions would be appreciated.

Replies are listed 'Best First'.
Re: Pack source code
by pg (Canon) on Dec 09, 2002 at 01:41 UTC
      I tried using the n and N methods when pack/unpack but it still does not seem to work on the other system - is it not possible to port it using pack at all?
Re: Pack source code
by tadman (Prior) on Dec 09, 2002 at 08:08 UTC
    What you might want to do is stay away from endian types and use only "network order" types. In pack, this is n and N. Character types should be fine. These can be packed and unpacked across different platforms with no data mangling.

    Barring that, maybe you could show, or at least describe the way you're packing your data.
Re: Pack source code
by John M. Dlugosz (Monsignor) on Dec 09, 2002 at 07:16 UTC
    Suggestion: make a toy script (or comment out bunches of stuff) so you have a program which only reads from the data and prints it. See if it works right on the "other" machine, under those circumstances.

    Write a toy program which just calls unpack on some literal data (not read from anywhere) and prints the results. See if it works the same on each machine.

    When you get something that doesn't work the same on all machines, come back and post just the stuff that works differently, and we should be able to enlighten.

    —John

Re: Pack source code
by submersible_toaster (Chaplain) on Dec 09, 2002 at 07:09 UTC
    And what , do tell , is it you plan to use this for? Even without endian issues, this is bound to be difficult. What makes this 'code' so crucial that you feel the need to bundle it up illegibly. <rhetoric> suggests changing node title to "What I'll try doing to your scripts if they're world writable"</rhetoric>