#!/usr/bin/perl # Listen to Death Metal....it rips! my ($next,$date,@when,$month,$day,$year,$mod_date,$file,$last_file,$lastfile,@lines,$last_date); my ($full_month,%suff,$title_date); # generic "next" or "not done yet" link $next = 'index.html'; # get today's date and feed it into an array $date = `date +%D`; @when = split(/\//,$date); # define m/d/y variables for today's date $month = $when[0]; $day = $when[1]; $year = $when[2]; # define the name of the write file $mod_date = join('',$month,$day,$year); chomp ($mod_date); $file = join('',$mod_date,'.html'); # file containing filename of last entry $last_file = 'last.cfg'; # open last entry and change the "next" link to today's entry # if no last entry exists, print a link to index.html if (-e $last_file) { $lastfile = &last(); chomp($lastfile); open(PREV, "+<$lastfile") || die "no can open - $lastfile $!\n"; @lines = ; foreach (@lines) { s/$next/$file/; } seek(PREV,0,0); print PREV @lines; close(PREV) || die "no can close read file - $lastfile: $!\n"; } else { open(LAST, ">$last_file") || die "no can make - $last_file $!\n"; print LAST "index.html"; close(LAST) || die "no can close write - $last_file: $!\n"; } open(FILE, ">$file") || die "no can make - $file $!\n"; # print out the header print FILE < $month.$day.$year
[back]
 
  WEBPAGE ; # print out the title (month and day) print FILE " ",&full_month," ",&suffixed,"

\n\n"; # slurp in content and place it in the body while (<>) { print FILE $_; }; # print footer with "next" link print FILE <

 

[next]
MOREWEBPAGE ; # change file in $last_file to today's entry open(LAST, ">$last_file") || die "no can make - $last_file $!\n"; print LAST "$file"; close(LAST) || die "no can close write - $last_file: $!\n"; ################ # Morbid Angel # ################ # get the filename of the previous entry sub last { open(LAST, "$last_file") || die "no can open - $last_file $!\n"; while (){ $last_date = $_; }; close(LAST) || die "no can close read file - $last_file: $!\n"; return $last_date; } # get the full name of the current month sub full_month { $full_month = `date +%B`; chomp ($full_month); return $full_month; } # get the correct suffix for today's numeric value (i.e. the "rd" in 3rd) sub suffixed { %suff = qw( 1 st 2 nd 3 rd 4 th 5 th 6 th 7 th 8 th 9 th 10 th 11 th 12 th 13 th 14 th 15 th 16 th 17 th 18 th 19 th 20 th 21 st 22 nd 23 rd 24 th 25 th 26 th 27 th 28 th 29 th 30 th 31 st); if ($day < 10) {$day =~ s/0//;} $title_date = join("",$day,$suff{$day}); return $title_date; }