Domanda

I would like to check syntax of my perl module (as well as for imports), but I don't want to check for dynamic loaded c libraries.

If I do:

perl -c path_to_module

I get:

Can't locate loadable object for module B::Hooks::OP::Check in @INC

because B::Hooks::OP::Check are loading some dynamic c libraries and I don't want to check that...

È stato utile?

Soluzione

You can't.

Modules can affect the scripts that use them in many ways, including how they are parsed.

For example, if a module exports

sub f() { }

Then

my $f = f+4;

means

my $f = f() + 4;

But if a it were to export

sub f { }

the same code means

my $f = f(+4);

As such, modules must be loaded to parse the script that loads it. To load a module is simply to execute it, be it written in Perl or C.


That said, some folks put together PPI to address the needs of people like you. It's not perfect —it can't be perfect for the reasons previously stated— but it will give useful results nonetheless.


By the way, the proper way to syntax check a module is

perl -e'use Module;'

Using -c can give errors where non exists and vice-versa.

Altri suggerimenti

The syntax checker loads the included libraries because they might be applying changes to the syntax. If you're certain that this is not happening, you could prevent the inclusion by manipulating the loading path and providing a fake b::Hooks::OP::Check.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top