Re: [Module::Build] dynamic creation?
Status: Beta
Brought to you by:
kwilliams
From: Randy W. S. <ml...@th...> - 2006-05-21 23:46:34
|
Gene Boggs wrote: > How do I generate the main, module_name package via the PL_files? I > have Module::Build 0.2801 and (as with previous versions) get this > instead of a Build file: > > ~/bin/Foo-Bar> perl Build.PL --foo=wtf > Can't find file lib/Foo/Bar.pm to determine version > at /usr/lib/perl5/site_perl/5.8.8/Module/Build/Base.pm line 934. By default M::B tries to find meta information about your distribution from the name of the distribution: abstract, author, version. The abstract and author come from parsing any POD in the "main" module file. The version is detected by primitive scanning with a regexp. So... Given your distribution name of 'Foo-Bar', M::B is looking for a file 'lib/Foo/Bar.pm' to detect the meta information. It doesn't find the file so it complains as above. You have two options to help M::B find the meta information. 1) specify it explicitly in your Build.PL file: my $build = Module::Build->new( module_name => 'Foo::Bar', dist_abstract => 'A module to Foo::Bar', # ADDED dist_version => '0.00_01', # ADDED dist_author => 'you <yo...@so...>', # ADDED license => 'perl', PL_files => { 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm', }, ); 2) You can tell it in which file to find the meta information: my $build = Module::Build->new( module_name => 'Foo::Bar', dist_version_from => 'lib/Foo/Bar.pm.PL', # ADDED license => 'perl', PL_files => { 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm', }, ); Note, however, that (2) may cause other problems. In particular, when scanning your file for the version it will find the line: our \$VERSION = '0.00_1'; which it will then try to evaluate to determine your version. This will fail because the line is not a line of perl code but a string which contains *escaped* perl code (I.E. the backslash). In order to make it work, you will need to "trick" the primitive parser we use to get the version. Currently, that can be done by adding at the top of your file a valid declaration package Foo::Bar; our $VERSION = '0.00_01; Option (1) is the safest and best approach. I can't guarantee that the workaround for (2) will always work. Regards, Randy. |