This repository has been archived on 2025-02-12. You can view files and clone it, but cannot push or open issues or pull requests.
NeoStats/tools/generate_header
2005-07-13 15:38:03 +00:00

33 lines
613 B
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
my $output = "neostats.pm.h";
open my $header, ">", $output or die "Couldn't open '$output': $!";
print $header header( "NeoStats.pm" );
close $header;
sub header {
my $file = shift;
open my $input, "<", $file or die "Couldn't open '$file':$!";
my @file = <$input>;
close $file;
return toc(@file);
}
sub toc {
my @lines = @_;
for( @lines ) {
if( /^\s*$/s ) { $_ = qq{"\\n"\n}; next; }
if( /^\s*#/ ) { $_ = qq{"\\n"\n}; next; }
s/\\/\\\\/g; # double the number of \'s
s/"/\\"/g;
s/^\s*/"/;
s/\n/\\n"\n/;
}
return @lines;
}