#!/usr/bin/perl
# w4.15.pl   The translation operator.

require("mylib.pl");
@twinkle = &get_lines("twinkle.txt"); 

print ("Try one: \n");
foreach (@twinkle){
   s/^\s*$//;                                   #get rid of blank lines
   tr/wr/xz/;
   }
print (@twinkle);


print ("\n\nTry two:\n");
foreach $the_line (@twinkle){
   $the_line =~ tr/[a-z]/[A-Z]/;
   }
print (@twinkle);


print ("\n\nTry three:\n");
foreach $the_line (@twinkle){
   $the_line =~ tr/[XZ]/[wr]/;

   }
print (@twinkle);


print ("\n\nTry four:\n");
foreach $the_line (@twinkle){
   $the_line =~ tr/[A-Z]/[a-z]/;
   }
print (@twinkle);


# Use ucfirst() to restore initial capitals
print ("\n\nTry five:\n");
foreach $the_line (@twinkle){
   $the_line=ucfirst($the_line);
   $the_line =~ s/\bi\b/I/;			#restore the word "I"
   }
print (@twinkle);


print ("\n\nTry six (code):\n");
foreach $the_line (@twinkle){
   $the_line =~ tr/[a-zA-Z]/[b-zaB-Za]/;	
   }
print (@twinkle);


print ("\n\nTry 7 (decode):\n");
foreach $the_line (@twinkle){
   $the_line =~ tr/[b-zaB-Za]/[a-zA-z]/;	
   }
print (@twinkle);



