I (think) I have something similar to what you're trying to do. It's a module. I, like others, like to keep modules and binaries separate. In all my distributions that require a user usable binary, I just add it in so it gets installed. To do so, I do this in the Makefile.PL script:

my %WriteMakefileArgs = ( NAME => 'Addr::MyIP', AUTHOR => q{Steve Bertrand <steveb@cpan.org>}, VERSION_FROM => 'lib/Addr/MyIP.pm', ABSTRACT_FROM => 'lib/Addr/MyIP.pm', LICENSE => 'artistic_2', EXE_FILES => [qw(bin/myip)], ...

... see the last line? That will install the distribution's myip binary located in the distribution's bin directory into their path.

My Addr::MyIP is one such module. The core of the functionality is in the Addr::MyIP library, and the script mentioned above is separate. This keeps my code nice and clean.

fwiw, I wrote that distribution (which fetches my devices public IP address) so that I can maintain VPN connections on the locations I have equipment even if they have dynamic/changing addresses.

I call that code from the update-ip binary in my Net::DNS::GoDaddy library, which then updates certain DNS A records for me through GoDaddy's API, so all of my locations are always up-to-date with their current public IP address. I can always use 'home.domain.com' for my home VPN connection etc.

Having the two files separate also makes it easier for others to hack at them, and for me to review the patches or pull requests. Documentation is separate, tests are separate, less chance I break one and not the other, and it doesn't have the feeling like there's executable code inside of a library. A library is to be read, not executed (imho), and executing a .pm file just seems so very wrong.


In reply to Re: Modulino to report ip address changes by stevieb
in thread Modulino to report ip address changes by davies

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.