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 $dashed_line = $shorter_name;
72 $dashed_line =~ s/./-/g;
74 $header_copy =~ s/%1/$shorter_name/;
75 $header_copy =~ s/%2/$dashed_line/g;
80 open(TO_DUMP, "<$to_dump");
84 local($just_started) = 1; # check for and remove blank lines at top of file.
89 #for ($i = 0; $i < length($line); $i++) {
90 #$curr_char = substr($line, $i, 1);
91 #print "[$curr_char]";
94 local($curr_char) = 0;
95 #print "start len=" . length($line) . "\n";
98 chop $line; # remove end of line char(s).
99 $curr_char = substr($line, length($line) - 1, 1);
100 # get new last char in string.
101 } while ( ($curr_char eq "\r") || ($curr_char eq "\n") );
102 local($do_print) = 1;
104 if (length($line) == 0) {
105 #continue; # skip the first blank lines.
106 $do_print = 0; #no continue statement??
109 # a non-blank line has been seen. now we reset our flag so we stop
110 # checking for blank lines.
112 #print "do print = $do_print\n";
114 if ($do_print) { print $line . "\n"; }