#!/usr/bin/perl #---------------------oOo------------------------- # Filename: mknote.pl # Usage: ./mknote.pl filename1.txt filename2.html # the output will be filename1.html filename2.html and so on # Coder: Tuan Trung Pham # Last update: April 12, 2003 1st release # Requirements: # 1) perl # 2) decent OS (*ix) with date and awk tools $NAME="Tuan Pham"; # put your darn name here $IndexFile=""; @FILENAME,@TITLE, $inputFile; # filename and title array main(); #--------------------------oOo--------------------------- # the job is done mainly by this subroutine => main() sub main { my $Body,$NextFile,$OutFile,$ThumbNail,$CurrentFile; my $i; my @A_PARA; my $bYear=""; my $Year=`date | awk '{print \$6}'`; # get the current year # $Body=""."\n"; while ($NextFile=shift(@ARGV)) { if ( -e $NextFile ) { $CurrentFile=$NextFile; $OutFile=$CurrentFile; $OutFile=~s/\.[^\.]+/\.html/; print "Processing \"$CurrentFile\"...\n"; # open this file # parse the title open (INPUT_FILE,"< $CurrentFile") # default is open(INPUT_FILE,"< $inputFile") readonly || die "Jebus! Can't read $CurrentFile\n fsck?"; open (OUTPUT_FILE,"> $OutFile") # || die "Jebus! Can't read $OutFile\n fsck?"; $Title=; # read the first line as the title for the index.html chomp $Title; # clean it makeHeader(); # make the header $Body=""; # parse all terms and definitions local($/)="\n\n"; while ($line=) # parse the terms and definition { chomp $line; # clean it! @temp_list=split(" ",$line); # split it into term and definition # now make a row with one cell for term and another cell for definition $Body=$Body." \n \n\n". " \n". " \n\n"; } $IndexFile=$IndexFile.$Body."\n\n". "
@temp_list[0]@temp_list[1]
\n". "\n". # make a horizontal line "
". "\n". " \n". " \n". " \n". "
\n". "
\n". "
\n". # (c) "\n". "\n". " \n". " ". "
\n". " \n"; $IndexFile.=" ©$Year $NAME
\n". "
\n". "
". "\n". ""; local($/)="\n"; print OUTPUT_FILE $IndexFile; close(INPUT_FILE); close(OUTPUT_FILE); } else { print STDERR "Broken arrow! Broken arrow! \"$NextFile\" doesnt exist!\n"; } } # while loop } #-------------------------oOo-------------------------- # makeHeader() # generate the the header for index.html sub makeHeader { $MyDate=localtime(); $IndexFile="\n". "\n". "\n". "\n". "$Title\n". "\n\n". "\n". "\n". "\n\n". "
\n\n". "\n"; }