#!/usr/bin/perl # # Try to intelligently capitalize words. # Lower-case everything, then look for periods followed by spaces. @allcaps = qw( acm afb afcert afcic aig dc dcdisa hq html tx usaf ); @firstcap = qw( april august december excel february january july june kelly march may microsoft november october powerpoint september washington ); @months = qw( apr aug dec feb jan jul jun mar may nov oct sep ); # Grab entire file undef $/; $_ = <>; # Force to lowercase, then upper-case special words and beginnings # of sentences. $_ = ucfirst lc ($_); while (/[\.\?!]\s+([a-z])/) { $x = uc ($&); $_ = $` . $x . $'; } while (/\n\n+([a-z])/) { $x = uc ($&); $_ = $` . $x . $'; } foreach $from (@allcaps) { $to = uc ($from); s/(\s)$from([,\.\s])/$1$to$2/g; } foreach $from (@firstcap) { $to = ucfirst ($from); s/([,\.\s])$from([,\.\s])/$1$to$2/g; } foreach $from (@months) { while (/(\s)$from([,\.\s])/) { $x = ucfirst ($from); $_ = $` . $1 . $x . $2 . $'; } } s/[Ee]xecutive\s+summary/Executive Summary/g; s/[Ii]nternet\s+explorer/Internet Explorer/g; s/Microsoft\s+office/Microsoft Office/g; s/[Ii]e\s+script/IE script/g; s/air force/Air Force/g; s/army/Army/g; s/navy/Navy/g; print "$_"; exit (0);