#!/usr/bin/perl
# w2.5.pl -- Perl strings

#1. chop(), chomp()  cut off (and return) last character 
#   chomp() cuts off only white space characters space, \n, \t, etc.
$str= "antidisestablishmentarians";
$c = chop($str);				
print ("1.  $str - $c\n");

#2. chr()  returns an ASCII character for its number value
$str = $str . chr(115);				
print ("2.  $str\n");

#3. uc()
$str = uc($str);
print ("3.  $str\n");


#4. lc()
$str= lc($str);
print ("4.  $str\n");

#5. ucfirst()
$str = ucfirst($str);
print ("5.  $str\n");

#6. lcfirst()
$str = lcfirst($str);
print ("6.  $str\n");

#7.  length() 
$l = length($str);
print ("7.  The length of $str is $l.\n");

#8.  reverse() 
$r = reverse($str);
print ("8.  The reverse of $str is $r.\n");

#9.  sprintf()
$sent = ("9.  The reverse of $str is $r.\n");
print ("$sent");


#10.  index()
$n = index($str,"dis");
print ("10. The string \"dis\" starts after char number $n.\n");


#11.  substr()
$l = $l - $n;
$str3 = substr($str,$n,$l);
$str4 = substr($str,$n,3);
print ("11. $str3     $str4\n");




#12. crypt()
$str2 = crypt($str, 99);		#use a two digit number for salt
print ("12.  $str2\n");


__END__

