I haven't used Perl2Exe, but I suspect this won't be possible. bar.pm as you describe it is intended to be a resource, whereas bar.exe would be a program.

The only way to accomplish this that I could think of would be to write another script that uses Bar.pm, and provides a command-line interface so you could perl2exe the new script, and make system calls with command-line arguments in foo.pl.

Frankly, I'd suspect that perl2exe won't provide much code protection anyway. Many of these 'create an exe out of a scripting language' programs just give you back an executable perl interpreter that's designed to look inside it's own file for the perl code to execute. (which means that anyone with an editor can open the exe, page through the binary garbage, and find your code at the end) If your desire is simply to protect your source, you'll be better off finding a tool specifically for that.


Xaositect - Whitepages.com

In reply to Re: Using Perl subroutines in a Perl2Exe exe file by Xaositect
in thread Using Perl subroutines in a Perl2Exe exe file by tlemons

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.