#!/usr/bin/perl use strict; use warnings; while (1) { open FIN, "<20070910_DianeRehm_JohnDean.html" or die; my $html = do {local $/=undef; }; close FIN; #print $html; exit; $html =~ s#.*#\n#si; #print $html; exit; open FOUT, ">20070910_DianeRehm_JohnDean.html" or die; print FOUT $html; sub p { print @_; print FOUT @_; } p "\n"; my $last_who = ''; my $para = 0; my $subpara = 0; open FIN, "<20070910_DianeRehm_JohnDean.txt" or die; while () { s/\s+$//si; if (!/\S/) { p "\n"; } next unless /\S/; my $orig = $_; if (s/^T //si) { p "
(mp3 mark $_)\n"; next; } elsif (s/^(D |Diane: |J |John: |\S*: )//si) { my $whofull = $1; my $who = substr($1, 0, 1); if ($last_who ne $who) { if ($who eq 'D') { $para++; $subpara = 0; p "
Diane:"; } elsif ($who eq 'J') { $para++; $subpara = 0; p "
John:"; } elsif ($whofull =~ s/:\s*$/:/) { $para++; $subpara = 0; p "
$whofull"; } else { warn "Uknown speaker '$who'\n\t$orig\n\t"; last; } } else { #p "
"; $subpara++; my $sp = chr(ord('a') + $subpara - 1); p "

"; } $last_who = $who; } else { warn "Uknown speaker\n\t$orig\n\t"; last; } s/ -- / — /gs; s#\*(.*?)\*#$1#gs; # italics p $_; p "\n"; } close FIN; close FOUT; last unless (grep /repeat/i, @ARGV); sleep 2; system "clear"; }