[RSS] Repository clover by nishi (Revision 13): /trunk/replace.pl

HTML 2.0 compliant static site generator

File Latest Commit

r3 | nishi | 2024-05-05 13:26:03 +0900 (Sun, 05 May 2024) | 1 line

some progress

#!/usr/bin/env perl
# $Id: replace.pl 3 2024-05-05 04:26:03Z nishi $
# To put LICENSE into the source code

use IO::Handle;

my $str = "";
while(<STDIN>){
	$str = $str . $_;
}

my $rep = 74;

my $repl = "/* " . ("-" x $rep) . " */\n";

my $io = IO::Handle->new();

if(open $io, '<', "HEADER"){
	my $len = 0;
	while(<$io>){
		my @list = $_ =~ /.{1,$rep}/g;
		for my $s (@list){
			if(length($s) > $len){
				$len = length($s);
			}
		}
	}
	$io->close;
	open $io, '<', "HEADER";
	while(<$io>){
		my @list = $_ =~ /.{1,$rep}/g;
		for my $s (@list){
			$repl = $repl . "/* " . (" " x ($rep - $len - 1)) . "$s" . (" " x ($len - length($s) + 1)) . " */\n";
		}
	}
	$repl = $repl . "/* " . ("-" x $rep) . " */\n";
}

$io = IO::Handle->new();

open $io, '<', "LICENSE" or die "$!";

while(<$io>){
	my @list = $_ =~ /.{1,$rep}/g;
	for my $s (@list){
		$repl = $repl . "/* $s" . (" " x ($rep - length($s))) . " */\n";
	}
}

$io->close;

$repl = $repl . "/* " . ("-" x $rep) . " */\n";

$str =~ s/\/\* --- START LICENSE --- \*\/\n(.+\n)?\/\* --- END LICENSE --- \*\//\/\* --- START LICENSE --- \*\/\n$repl\/\* --- END LICENSE --- \*\//gs;
print $str;
Powered by SwineHub Version: 1.503-gcc $Id: swinehub.h 130 2023-11-14 20:23:25Z nishi $ Copyright