in reply to Perl syntax checking without `perl -c`

For a really crude workaround, you could hook into the require subsystem to return empty files for missing modules:
# workaround.pm BEGIN { push @INC, sub { my ($self, $filename) = @_; return \"1;"; }; } 1;
$ perl -Mworkaround -MFoo::Bar -E' say "still alive"; ' still alive

Replies are listed 'Best First'.
Re^2: Perl syntax checking without `perl -c`
by hippo (Archbishop) on Dec 06, 2020 at 11:59 UTC

    No need to hack it up yourself when there's a module for that: Acme::Anything.


    🦛

Re^2: Perl syntax checking without `perl -c`
by perlfan (Parson) on Dec 03, 2020 at 18:10 UTC
    This is not "crude" and actually a good solution; that often times you definitely want things to fail if prerequisite modules are not found. And if you're requiring libs over a network mounted drive, you're gonna have a bad time.

      I just can't understand why someone capable of giving such a valuable contribution disguises himself as the Anonymous Monk.

      Greetings,
      -jo

      $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
        Thanks for the kind words! Personally, I just don't like logging in. Websites still allowing anonymous posting (like PerlMonks and the SQLite forum) are like a breeze of fresh air to me. Ironically, I had to log in to post this because I kept getting "Tough beans" otherwise.