use HTML::FromANSI (); open (LOG, '>>hnchatlog.html'); select((select(LOG), $|=1)[0]); print LOG "\n"; while (<>) { my $h = HTML::FromANSI->new(); print LOG $h->ansi_to_html($_), "\n"; }