# No.17 Perl Sample (code key - 34) # Learning Perl: Convert text to lower case 2(大文字を小文字に変換する) # Tomonori Nagano # Last Update: January 18, 2008 # # This file is encoded in Unicode (UTF-8). If you see gibberish characters, # please re-encode the file in utf-8. # # this sample script is simplified for pedagogical purposes. Those who are # interested in advanced Perl programming are encouraged to consult with # relevant sections of "Perl Cookbook" by Christiansen & Torkington while(<>){ chomp ; # delete the end-of-line character @chars = split("",$_) ; # split into each character foreach $char (@chars) { # process each character $val = ord($char) ; # convert into the ascii value # if in the range of 65-90 (upper-case letters) increase the value # by 32 (so that it becomes the value of corresponding lower case char $val = $val + 32 if ($val <= 90 && $val >= 65) ; $char = chr($val) ; # convert into characters print $char ; } print "\n" ; # add an end-of-line character }