Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • My module start point is just a directory of TT templates that I process with ttree. When I want to change the templates, I don't deal with 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;
            }