33 lines
613 B
Perl
Executable file
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;
|
|
}
|