Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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', '' ), File::Spec->catfile( 'lib', $file ); sub prompt { print join "\n", @_; print "> "; my $line = <STDIN>; chomp $line; $line; }
brian d foy <>
Subscribe to The Perl Review

In reply to Re: Best Module Starter? by brian_d_foy
in thread Best Module Starter? by dynamo

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2022-12-06 09:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found