Hi all,

I would like to have a shorter Build.PL for cases where a distribution 
contains no modules.  That is, it consists of just qw(Build.PL bin/foo) 
(and maybe 't/basic.t'.)

At present, Build.PL requires these parameters:

  dist_name     => 'bin-foo',
  dist_version  => 'v0.0.1',
  dist_author   => 'Eric Wilhelm @ <ewilhelm at cpan dot org>',
  dist_abstract => 'does some thing',

For a module-based distribution, those can all come from lib/foo.pm 
given only a 'module_name' parameter.  I would rather not duplicate 
them if they are already in the 'bin/foo' pod.

So, I would like to add a 'program_name' parameter which behaves as if 
you had said:

  dist_name         => 'bin-foo',
  dist_version_from => 'bin/foo',

(And there's one nit involving ModuleInfo.pm's assumption about the main 
package, but that can be fixed by explicitly passing the module 
parameter.)

The requirement would be that '$bin::foo::VERSION' gets defined (I want 
to discourage setting $main::VERSION) and that there is pod.  Thoughts?

An example (bare minimum)

  #!/usr/bin/perl
  $bin::thing::VERSION = v0.0.1;

  =head1 NAME

  thing - a deal for stuff

  =head1 AUTHOR

  Eric Wilhelm @ <ewilhelm at cpan dot org>

  =cut

  # code goes here


Here's a more formalized example.  The use of a bin::thing::main() 
subroutine makes testing and refactoring easier.

  #!/usr/bin/perl
  package bin::thing;
  $VERSION = v0.0.1;

  use warnings;
  use strict;

  =head1 NAME

  thing - a deal for stuff

  =head1 AUTHOR

  Eric Wilhelm @ <ewilhelm at cpan dot org>

  =cut

  sub main {
    my (@args) = @_;
    # meat of code goes here
  }

  package main;

  if($0 eq __FILE__) {
    bin::thing::main(@ARGV);
  }

  # vi:ts=2:sw=2:et:sta
  my $package = 'bin::thing';


--Eric
-- 
To a database person, every nail looks like a thumb.
--Jamie Zawinski
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to