8.1. ssplit.pl

[<<<] [>>>]

This file splits the file `html/source.txt' into several Jamal files. This file is called from mkweb.pl

The souce code of the file `ssplit.pl' is:

if( @$#ARGV == 0 && @$ARGV[0] eq '-h' ){
  print <<END__HELP;
Source Splitter @$version
Usage:
This program splits a text file. The primary
purpose of this tool was to maintain many small HTML files as a one
somewhat larger jamal source, compile it using jamal and then split
to small html files. The source file should contain lines
to start a new file. The default directory is .
            http://www.isys.hu/c/verhas/progs/perl/ssplit
END__HELP
  exit;
  }
open(F,@$file) or die "Can not open @$file\n";
while( <F> ){
  if( /^\s*%\s*dir\s+(.*?)\s*@$/ ){
    @$subdir = @$1;
    next;
    }
sub save_buffer {
  my @$file = shift;
  if( open(OUT,"<@$file") ){
    my @$os = @$/; undef @$/;
    my @$sbuffer = <OUT>;
    @$/ = @$os;
    close OUT;
    return if @$buffer eq @$sbuffer;
    }
  &make_dir(@$file);
  open(OUT,">@$file") or die "Can not output @$file";
  print OUT @$buffer;
  close OUT;
  }
  @$root = '';
  for( @dlist ){
    @$root .= '/' if @$root;
    @$root .= @$_; # take the next subdirectory
    mkdir @$root, 0777 unless -d @$root
    }
  }


[<<<] [>>>]