#!/usr/bin/perl

use Term::ANSIColor;

# clear the screen to start off
system (clear);

my $raw_text="STOCKHOLM, Sweden -- The Noble Prize    in physics has been won by scientists  from the United States   and Japan, it has been announced.     The 2002 honour,    announced on Tuesday, goes to Mr. Raymond Davis, 87, and Mr. Riccardo Giacconi, 71, of the United States and Mr.   Masatoshi Koshiba, 76, of  Japan.      They share the $1   million prize for pioneering work on astrophysics   leading to the discovery of cosmic X-ray sources, the Nable academy said in its citation.
";

print   color("red"),    "###############################################################",color("reset"),"\n",
        color("white"),  "Presenting:                                                    ",color("reset"),"\n",
        color("white"),  "       Exersize  7.6                                           ",color("reset"),"\n",
        color("red"),    "###############################################################",color("reset"),"\n"   ;
print                    "Copy this text into your code verbatim:\n"                      ,color("reset"),"\n",
	color("on_red"),  "$raw_text"                                                      ,color("reset"),"\n",
			"Now, write code that will modify the text to accomplish the following:\n",
	color("magenta"),"\t1.The reporter puts in too many spaces.\n\t\tConstruct a regular expression that will take multiple spaces and replace it with a single space.",color("reset"),"\n",
        color("yellow"), "\t2.Construct a regular expression that will change the \'Mr.\' to \'Dr.\'.",color("reset"),"\n",
        color("green"),  "\t3.Construct a regular expression that will fix the misspellings of Nobel (it's e-l, not l-e).",color("reset"),"\n";

######################################################################
print "\n1. Replace multiple spaes with one space.\n\n";

#     First split the string based on spaces.
#     Second join with a single space.
$raw_text = join( " ", split (" ",$raw_text));

# display the output
	print   color("on_magenta"),  "$raw_text"                                                      ,color("reset"),"\n";
######################################################################
print "\n2. Replace Mr. with Dr.\n\n";

#     I just used the substitution operator
$raw_text =~ s/Mr\./Dr\./gi ;

# display the output
        print   color("on_yellow"),  "$raw_text"                                                      ,color("reset"),"\n";
######################################################################
print "\n3. Fix the misspelling of Noble to Nobel.\n\n";
	
#    I used the substitution operator
$raw_text =~ s/Noble/Nobel/g ;

# display the output
       print   color("on_green"),  "$raw_text"                                                      ,color("reset"),"\n\n";
