in reply to Re^2: Perl syntax checking without `perl -c` (bareword)
in thread Perl syntax checking without `perl -c`

"Hence you'll need to fake-export them too. ;)"

Yes, I was aware of that and even considered doing it. The main criteria, when thinking about doing that, were: how long that would take; how long disaster recovery would take; and, what useful coding I would not be doing while doing this instead.

I tend not to make too many mistakes. Mostly they involve keyboard errors: not pressing or releasing the shift key fast enough; hitting an adjacent key by mistake; and the like. E.g.

my @x = qw{a b c}: # slow release of shift: got ':' instead of ';' my $y - $x[2]; # hit adjacent key: got '-' instead of '='

Thankfully these are pretty rare and easily fixed.

Other types of errors, such as logic errors, are not syntax errors and are only found when testing.

— Ken

Replies are listed 'Best First'.
Re^4: Perl syntax checking without `perl -c` (bareword)
by LanX (Saint) on Dec 05, 2020 at 01:48 UTC
    > how long that would take; how long disaster recovery would take; and, what useful coding I would not be doing while doing this instead.

    yeah, that's what I meant initially, how much does one want to invest for a temporary 90% solution.

    But this thread has also become an intellectual challenge and it's still possible to have a better solution.

    So for completeness:

    The dynamic %INC hook shown here could be extended to provide an import routine which exports all symbols requested.

    This won't cover subs with special prototypes or subs which are exported by defaults though, but will get you closer to your "unreasonable" goal. ;-)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      "So for completeness: ..."

      The following is somewhat negative information, but perhaps useful to know for someone coming to this thread in the future.

      I had previously done an internet search for "perl lint". I came across these two modules:

      B::Lint

      In its raw form (i.e. perl -MO=Lint file_with_perl_code) this seemed to act pretty much identically to perl -c file_with_perl_code. It does have a number of options but none turn off executing code.

      Perl::Lint

      I think this falls into the category of abandonware: not touched in over four years; about 95% of testers failed to install the module; dead link to TPF grant proposal.

      I did manage to force-install it; however, running it with my $work code produced errors (related to Perl::Lint code). I created a very simple bad.pl (with the typos I indicated above) purely as a test: although its SYNOPSIS shows running it on a bar.pl file, it complained about no package declaration; not ending with 1;; and other things which suggest the code only works on modules, not scripts.

      — Ken