3 ###############################################################################
6 # Author : Chris Koeritz #
7 # Rights : Copyright (C) 1996-$now by Author #
11 # Smashes multiple text files together into one large text file. #
13 ###############################################################################
14 # This program is free software; you can redistribute it and/or modify it #
15 # under the terms of the GNU General Public License as published by the Free #
16 # Software Foundation; either version 2 of the License or (at your option) #
17 # any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
18 # version of the License. Please send any updates to "fred@gruntose.com". #
19 ###############################################################################
21 require "filename_helper.pl";
28 # iterate over the list of files and dump them to standard output.
30 foreach $filename (sort &glob_list(@ARGV)) {
36 ############################################################################
41 filedump: this program needs a set of filenames to print out. they will
42 be dumped to the standard output.
47 ############################################################################
49 # do_dump: prints the contents of the first parameter's file out to stdout.
55 # print "dumpfile=$to_dump\n";
65 $header_copy = $header;
66 $shorter_name = $to_dump;
67 $shorter_name =~ s/^\.\///;
68 $shorter_name =~ s/\.txt$//;
69 $shorter_name =~ s/_/ /g;
71 # we're using the extra equals in front as an almost uniquifier for the
72 # header lines. we then can treat any matching line as a header, although
73 # some input files could trick this heuristic.
74 $munged_name = "= $shorter_name";
75 $dashed_line = $munged_name;
76 $dashed_line =~ s/./=/g;
78 $header_copy =~ s/%1/$munged_name/;
79 $header_copy =~ s/%2/$dashed_line/g;
84 open(TO_DUMP, "<$to_dump");
88 local($just_started) = 1; # check for and remove blank lines at top of file.
93 #for ($i = 0; $i < length($line); $i++) {
94 #$curr_char = substr($line, $i, 1);
95 #print "[$curr_char]";
98 local($curr_char) = 0;
99 #print "start len=" . length($line) . "\n";
102 chop $line; # remove end of line char(s).
103 $curr_char = substr($line, length($line) - 1, 1);
104 # get new last char in string.
105 } while ( ($curr_char eq "\r") || ($curr_char eq "\n") );
106 local($do_print) = 1;
108 if (length($line) == 0) {
109 #continue; # skip the first blank lines.
110 $do_print = 0; #no continue statement??
113 # a non-blank line has been seen. now we reset our flag so we stop
114 # checking for blank lines.
116 #print "do print = $do_print\n";
118 if ($do_print) { print $line . "\n"; }