in reply to Best Module Starter?
This is the topic of one of my TPJ columns: Making New Distributions.
I use Template Toolkit. I create a directory of templates that do exactly what I want then process it with ttree. I can make the templates any way that I like without fooling with someone else's idea of what they should be, and my template cooker script can set any variables it likes so I don't have to specify those with the command.
I've made it even easier since I wrote that article. I use it this like:
prompt> module_cooker Foo::Bar
Here's the code:
#!/usr/bin/perl use Cwd; use File::Spec; my $module = $ARGV[0] || prompt( "Module name> " ); my $dist = $module; $dist =~ s/::/-/g; my $file = $module; $file =~ s/.*:://; $file .= ".pm"; my $cwd = File::Spec->catfile( cwd(), $dist ); system join " ", "/usr/local/bin/ttree" , "-s ~/.templates/modules" , "-d $cwd" , "-define module='$module'" , "-define module_file='$file'" , "-define module_dist='$dist'" ; chdir $dist; ( my $base = $module ) =~ s/.*:://; rename File::Spec->catfile( 'lib', 'Foo.pm' ), File::Spec->catfile( 'lib', $file ); sub prompt { print join "\n", @_; print "> "; my $line = <STDIN>; chomp $line; $line; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Best Module Starter?
by dynamo (Chaplain) on Nov 09, 2007 at 04:52 UTC | |
Re^2: Best Module Starter?
by Monk::Thomas (Friar) on Jun 20, 2013 at 09:46 UTC |
In Section
Seekers of Perl Wisdom