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

I'm in the process of trying out Perl2exe to compile my PERL script into an executable file (Windows platform). I had no problem creating the file (no compile errors or warnings), but when I ran the file as a test in a scenario where it has to output text created with pod:usage, the screen spits out garbage and beeps like crazy. I have contacted perl2exe support and they are not responding. I also Googled the topic but can't seem to find any threads on this issue.

I was curious if anyone else was aware of this issue and any known workarounds to use POD, or if there were any recommendations on a program besides Perl2exe that I can use to create a binary executable from a PERL script? Thank you.

Replies are listed 'Best First'.
Re: Perl2Exe and POD
by choroba (Cardinal) on Mar 18, 2011 at 16:42 UTC
    If I remember correctly (no MSWin box at hand), one of my students was able to read from __DATA__ in an EXE file, if he moved the section to a separate module. Maybe it might work for =pod as well?

      Thanks Coroba. By separate module you mean a separate file (a text file) correct (like the other suggestions on this thread)? I would like to find a solution where I could wrap up the whole thing in a single EXE for mobility, but it doesn't look like that's possible. Instead I think I will end up writing simple print statements for error and usage output. Thanks for the suggestion.

        Module is a text file named *.pm (see perlmod). But I guess it gets exe-fied together with your code. Or is it a different exe creator?
Re: Perl2Exe and POD
by Anonymous Monk on Mar 18, 2011 at 15:41 UTC
    an .exe is a binary file, to use pod2usage, you have to do something like ppselfdoc

      I know an exe is binary - I'm not sure what you are suggesting. I am using pod::usage to output text messages from my script when needed, like a help and man screen. When running the EXE, it should work the same as running the script e.g.,

      script.pl -h -> print help text

      script.exe -h -> print help text

      Shouldn't this behave the same? Thanks

        Pod::Usage works by reading the (Perl) source code of your main program. Ideally, Pod::Usage would know about how you packed your Perl program into an .exe format file, but it doesn't, so it can't extract the source code of your main program to create the help text. This is why it won't work without you doing some work.

        I'm not sure what you are suggesting.

        I showed you one solution, based on PAR. perl2exe has similar caveats, and a similar solution (give pod2usage a text file with pod to read)

        When running the EXE, it should work the same as running the script e.g.,.... Shouldn't this behave the same? Thanks

        No. pod2usage reads $0 (a text file, a perl program) unless you tell it different. With perl2exe $0 is the binary file .exe, so you need to tell pod2usage to read a text file, not the .exe