From b571a455f174e4ba0cde9f3e98ad09c60e24f95c Mon Sep 17 00:00:00 2001 From: Jonathan Blake Date: Mon, 12 Aug 2019 20:44:27 -0700 Subject: [PATCH] Print section numbers in header --- common/scripts/split-sections.pl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/scripts/split-sections.pl b/common/scripts/split-sections.pl index f16d2a8..1c1c8b8 100755 --- a/common/scripts/split-sections.pl +++ b/common/scripts/split-sections.pl @@ -1,4 +1,15 @@ #!/usr/bin/env perl +# +# Split single text file with numbered sections into multiple files, +# one per section. +# +# Simple Bash script to add title to the resulting files: +# +# for i in `seq 1 350`; do +# sed -i '1s/^/The Storms of Chai\n/' $i.txt; +# done +# +# See https://www.projectaon.org/en/Sanctum/Howto-proofread use strict; use autodie; @@ -21,7 +32,8 @@ while ($line = <>) { $filename = "$section.txt"; print STDERR "DEBUG: Starting section $section\n" if $debug; close $fh if $fh->opened(); - open ($fh, ">>$filename") or die "Couldn't open file $filename, $!" + open ($fh, ">>$filename") or die "Couldn't open file $filename, $!"; + print $fh "Section $section\n"; } # Print to the file if we have a filehandle except for the -- 2.17.1