From jacobson@math-cs.cns.uni.edu Tue Jul 16 17:10:08 2002 Date: Tue, 16 Jul 2002 10:53:26 -0500 (CDT) From: Mark Jacobson To: 810-088-06@uni.edu Subject: Finished hands-on class example... Here is the finished example program from today's hands-on class in Wright 112 lab. $htmlFiles = `ls *.html`; # back tic symbol, same key as tilde ~ print $htmlFiles; print "\nWhat file would you like to covert? "; $fileName = <>; chomp $fileName; open (FILE, $fileName); $fileName =~ s/.html/.converted/i; # i for ignore case, no need for # g as in global here. print "\nIs $fileName OK for the output file? y or n "; $answer = <>; chomp $answer; $answer = lc $answer; if ($answer eq "y") # use eq, not == for String compares { $fileNameOut = $fileName; } else { print "\nWhat filename would you like for output results instead? "; $fileNameOut = <>; chomp $fileNameOut; } open (OUTFILE, ">$fileNameOut"); $doubleQuote = "\""; while () # You have this part as 07/16/2002 { # hands-on class handout... chomp; $_ =~ s/"/\\"/g; # g means global option, substitute # and replace ALL occurrences of " # with \" in the $_ variable. $_ = "$doubleQuote $_ \\n$doubleQuote +\n"; print OUTFILE $_; } close FILE; close OUTFILE;