in reply to Unable to release modulino to CPAN

What is this all about?

#!/usr/bin/perl use strict; use warnings; use FindBin qw($RealBin); use File::Find; use feature 'say'; find ({wanted =>\&wanted, follow => 1 }, ($RealBin . '/..', @INC)); sub wanted { if ($File::Find::name =~ m/App\/ipchgmon.pm$/) { # Changed from "perl" to "$^X" per Slaven Rezic's advice # in issue 144972. I wouldn't have got near this issue # on my own. Many thanks, Slaven. my $cmd = join " ", $^X, $File::Find::name, @ARGV; say qx($cmd 2>&1); exit; } }

Why aren't you using

#!/usr/bin/perl use App::ipchgmon; App::ipchgmon::run();

Of course, you'll need to move the top-level stuff into run, and fix the incorrect package name in the module.

Replies are listed 'Best First'.
Re^2: Unable to release modulino to CPAN
by davies (Monsignor) on Oct 31, 2022 at 20:02 UTC

    This is an attempt to ensure that the same code is called in the same way whether during developer testing, installation testing or production. I am trying to avoid anything like your App::ipchgmon::run line, as that would mean moving the option parsing out of the modulino. I understand StevieB's recommendation about having the invoker, POD and module as separate files, but I don't like it as I have the scars from separating them. If I knew enough about all the operating system issues, I'd prefer to change this to a simple link to the modulino, but I don't think I could do it in an OS-agnostic way for Windows and Linux, let alone others I don't use. But I'll happily listen to help and advice.

    Regards,

    John Davies

      This is an attempt to ensure that the same code is called in the same way whether during developer testing, installation testing or production

      It has no such benefit over the code I posted.

      If anything, the fragility of your approach has the opposite effect of the one that's desired.

      App::ipchgmon::run line, as that would mean moving the option parsing out of the modulino

      You just said you wanted to use the same approach everywhere, so that's a good thing. The script calls run. The modulino calls run. You get the same code both ways.

      But why are you using a modulino at all? You just said you wanted to always call the code in the same way. But making it a modulino does the exact opposite of that. It gives you two ways to use the module, and two ways of running the tool.

      I'd prefer to change this to a simple link to the modulino

      Why??? Hacks upon hacks for no benefit.