Module-Extract-Use

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


1.044 2019-12-18T02:38:56Z
	* Bump this to a user release.

1.043_02 2019-12-17T12:55:00Z
	* Small fixes

1.043_01 2019-12-17T12:29:57Z
	* handle a couple of new cases:
	- include the modules specified by parent or base
	- find the require's in expressions, like `my $r = require Foo`

1.043 2017-02-03T03:24:02Z
	* Clarified license (GitHub issue #3 https://github.com/briandfoy/module-extract-use/issues/3)

1.042 2017-02-01T02:46:27Z
	* The -l and -j options work on the list of namespaces from all 
	files together instead of the list per file. Otherwise strict 
	and warnings always show up multiple times!

1.041 2017-02-01T01:58:04Z

Makefile.PL  view on Meta::CPAN

a module.

To build the distribution, run this file normally:

	% perl Makefile.PL

But, it's more interesting than that. You can load it with C<require>
and call C<arguments> to get the data structure it passes to
C<WriteMakefile>:

	my $package = require '/path/to/Makefile.PL';
	my $arguments = $package->arguments;

Note that C<require>-ing a file makes an entry in C<%INC> for exactly
that name. If you try to C<require> another file with the same name,
even from a different path, C<require> thinks it has already loaded
the file. As such, I recommend you always require the full path to the
file.

The return value of the C<require> is a package name (in this case,
the name of the main module. Use that to call the C<arguments> method.

corpus/state_require.pm  view on Meta::CPAN


sub do_it {
	state $rc = require ConfigReader::Simple;
	}

my $rc = require Mojo::Util;

my %data = (
    require	=> 42,	# Should not report '=>'.
);

1;

lib/Module/Extract/Use.pm  view on Meta::CPAN

	use Foo;
	require Foo;

	use Foo 1.23;
	use Foo qw(this that);

It now finds C<require> as an expression, which is useful to lazily
load a module once (and may be faster):

	sub do_something {
		state $rc = require Foo;
		...
		}

Additionally, it finds module names used with C<parent> and C<base>,
either of which establish an inheritance relationship:

	use parent qw(Foo);
	use base qw(Foo);

In the case of namespaces found in C<base> or C<parent>, the value of

lib/Module/Extract/Use.pm  view on Meta::CPAN

	# this handles the
	#   use Foo;
	#   use Bar;
	my $regular_modules = $self->_regular_load( $Document );

	# this handles
	#   use parent qw(...)
	my $isa_modules      = $self->_isa_load( $regular_modules );

	# this handles
	#   my $rc = require Foo;
	my $expression_loads = $self->_expression_load( $Document );

	my @modules = map { @$_ }
		$regular_modules,
		$isa_modules,
		$expression_loads
		;

	return \@modules;
	}



( run in 0.261 second using v1.01-cache-2.11-cpan-0d8aa00de5b )