updated git and svn scripts
[xrzperl.git] / epub_merge_text
blob04ea922ff9718a083733bb4ea0b3f1517f19160b
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 BEGIN
9 my $PROGRAM_DIR = $0;
10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
12 unshift @INC,
13 map "$PROGRAM_DIR$_",qw{modules lib ../modules ..lib};
16 my %OPTS;
17 my @OPTIONS = qw/help|h|? version|ver edit-me manual|man language|lang zh en/;
19 if(@ARGV)
21 require Getopt::Long;
22 require MyPlace::Usage;
23 Getopt::Long::GetOptions(\%OPTS,@OPTIONS);
24 MyPlace::Usage::Process(\%OPTS,$VERSION);
26 else
28 require MyPlace::Usage;
29 MyPlace::Usage::PrintHelp();
31 $OPTS{language}='zh' if($OPTS{zh});
32 $OPTS{language}='en' if($OPTS{en});
34 my $content_title = 'content';
35 if($OPTS{language} and $OPTS{language} eq 'zh') {
36 $content_title = "目录";
39 my @files = @ARGV;
41 if(! @files)
43 # print STDERR "Input filenames please.\n";
44 while(<STDIN>) {
45 chomp;
46 push @files,$_;
50 die("Usage:$0 [options] file1 [file2...]\n") unless(@files);
51 print STDOUT "$content_title\n\n";
52 local $/=undef;
53 foreach(@files)
55 my $title = $_;
56 $title =~ s/.*\///;
57 $title =~ s/\.[^.]*$//;
58 print STDOUT " $title\n"
60 foreach(@files)
62 open FI,"<",$_ or die("$!\n");
63 my $title = $_;
64 $title =~ s/.*\///;
65 $title =~ s/\.[^.]*$//;
66 print STDOUT "\n$title\n";
67 print STDOUT <FI>;
68 close FI;
71 __END__
73 =pod
75 =head1 NAME
77 epub_merge_text - merge texts and build a content according to each file name
79 =head1 SYNOPSIS
81 epub_merge_text [options] ...
83 =head1 OPTIONS
85 =over 12
87 =item B<--version>
89 Print version infomation.
91 =item B<-h>,B<--help>
93 Print a brief help message and exits.
95 =item B<--manual>,B<--man>
97 View application manual
99 =item B<--edit-me>
101 Invoke 'editor' against the source
103 =back
105 =head1 DESCRIPTION
107 ___DESC___
109 =head1 CHANGELOG
111 2010-06-08 xiaoranzzz <xiaoranzzz@myplace.hell>
113 * file created.
115 =head1 AUTHOR
117 xiaoranzzz <xiaoranzzz@myplace.hell>
119 =cut