in reply to Re: Perl syntax checking without `perl -c`
in thread Perl syntax checking without `perl -c`

Another workaround I sometimes use at work is to create a fakelib/ directory with contents created like
echo 1 > SomeMod.pm

Then include fakelib into your PERL5LIB (or run perl -I /path/to/fakelib).

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^3: Perl syntax checking without `perl -c`
by Fletch (Bishop) on Dec 03, 2020 at 14:58 UTC

    Seconded; I've used basically the same thing letting flycheck run on my desktop working copy at $work so that it's perl -c check behaves even though I don't have the same perl environment available as the production machines where the code actually runs.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      The problem I see with this filesystem approach is maintenance.

      What if a missing module was installed in the meantime?

      A module "FakeInc" called via something like perl -MFakeInc -c could check if the module is available before installing a facade.

      ~~~

      Thinking about it, having a code hook at the last position of @INC could also handle all missing modules...

      from require : You can also insert hooks into the import facility by putting Perl code directly into the @INC array. There are three forms of hooks: subroutine references, array references, and blessed objects.

      update

      oops ... I didn't realized there was already a demo: Re: Perl syntax checking without `perl -c`

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

        "from require : You can also insert hooks into the import facility by putting Perl code directly into the @INC array. There are three forms of hooks: subroutine references, array references, and blessed objects."

        Well I'll be damned. All my years of Perl, and I've never known this. Man, I've been in several situations where this would have been handy. Off to play around...

Re^3: Perl syntax checking without `perl -c`
by LanX (Saint) on Dec 03, 2020 at 14:49 UTC
    Yeah, that's another good approach.

    I think it depends how many modules one needs to fake and often one needs them.

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