8 our $PROGRAM_DIR = $ENV{XR_PERL_SOURCE_DIR
};
11 $PROGRAM_DIR =~ s/[^\/\\]+$//;
12 $PROGRAM_DIR =~ s/(.)\/+$/$1/;
13 $PROGRAM_DIR = "." unless($PROGRAM_DIR);
16 map "$PROGRAM_DIR/$_",qw{modules lib
../modules
..lib
};
19 my @OPTIONS = qw
/stdout|o stdin|i simple|s help|h|? version|ver edit-me manual|man/;
23 require MyPlace
::Usage
;
24 Getopt
::Long
::GetOptions
(\
%OPTS,@OPTIONS);
25 MyPlace
::Usage
::Process
(\
%OPTS,$VERSION);
29 require MyPlace
::Usage
;
30 MyPlace
::Usage
::PrintHelp
();
35 my $module_name=shift;
37 require MyPlace
::Usage
;
38 MyPlace
::Usage
::PrintHelp
();
43 my $OUTPUT_DIR=$PROGRAM_DIR . "/modules";
47 open FO
,">&STDOUT" or die("fatal: can't not duplicate STDOUT\n");
50 my $pn = $module_name;
52 die "Can't not locate script directory.\n" if(!$OUTPUT_DIR);
53 die "Direcoty not exists:\"$OUTPUT_DIR\"\n" if (! -d
$OUTPUT_DIR);
54 my $fn="$OUTPUT_DIR/$pn.pm";
56 $dn =~ s/\/[^\/]+$/\//;
58 system("mkdir","-p",$dn) and die("$!\n");
60 exit system("r-vim",$fn) if(-f
$fn);
61 open FO
,"|-","r-vim - -c \"file \"$fn\"\"" or die("$!\n");
69 @TEXT = ("#!/usr/bin/perl -w\n","use strict;\n");
74 elsif(open FI
,"<","$OUTPUT_DIR/perl_module.template") {
85 our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,%EXPORT_TAGS);
95 use Env qw
/USER HOSTNAME/;
96 use POSIX qw
/strftime/;
97 my $DATE= strftime
("%Y-%m-%d %H:%M",localtime());
98 $USER="xiaoranzzz" unless($USER);
99 my $EMAIL="$USER\@" . (defined $HOSTNAME ?
$HOSTNAME : "myplace.hell");
101 s/___NAME___/$module_name/g;
102 s/___AUTHOR___/$USER/g;
103 s/___EMAIL___/$EMAIL/g;
104 s/___DATE___/$DATE/g;
115 pmnew - create new perl module
119 pmnew [options] <module name>
125 =item B<-i>,B<--stdin>
127 Read template from STDIN
129 =item B<-o>,B<--stdout>
133 =item B<-s>,B<--simple>
135 Disable using template.
139 Print version infomation.
141 =item B<-h>,B<--help>
143 Print a brief help message and exits.
145 =item B<--manual>,B<--man>
147 View application manual
151 Invoke 'editor' against the source
157 =item B<$XR_PERL_MODULE_DIR>
159 Output directory environment variable
161 =item $XR_PERL_MODULE_DIR\B<perl_module.template>
169 Create perl module with custumized template. By default, created module
170 will saved in directory "$XR_PERL_MODULE_DIR".
174 2008-05-06 15:07 xiaoranzzz <xiaoranzzz@myplace.hell>
176 * initial version 0.1
178 2010-11-09 20:56 xiaoranzzz <xiaoranzzz@myplace.hell>
180 * rewrote, version 0.2
184 xiaoranzzz <xiaoranzzz@myplace.hell>