Saturday, December 28, 2019
Perl String lc() Function
Starting out with a new programming language can be challenging. Learning the functions is one way to go about it. The Perl string lc() function and uc() function are two basic functions that are easy to understandÃ¢â¬âthey convert a string to all lowercase or all uppercase respectively. PerlÃ String lc() Function TheÃ PerlÃ lc()Ã function takes a string, makes the entire thing lowercase and then returns the new string. For example: #!/usr/bin/perl $orig_string This Test Is Capitalized; $changed_string lc(Ã $orig_string ); print The Resulting String is: $changed_string\n; When executed, this code yields: The Resulting String is: this test is capitalized First, $orig_string is set to a valueÃ¢â¬âin this case, This Test Is Capitalized. Then the lc() function is run on $orig_string. The lc() function takes the entire string $orig_string and converts it to its lowercase equivalentÃ and prints it out as instructed. PerlÃ String uc() Function As you might expect, Perls uc() function converts a string to all uppercase characters in the same manner. Just substitute uc for lc in the example above, as shown: #!/usr/bin/perl $orig_string This Test Is Capitalized; $changed_string uc(Ã $orig_string ); print TheÃ Resulting String is: $changed_string\n; When executed, this code yields: The Resulting String is: THIS TEST IS CAPITALIZED About Perl Perl is a feature-rich programming language that was originally developed for use with text. It is cross-platform and runs on more than 100 platforms. Perl works with HTML and other markup languages, so it is frequently used in web development.Ã Check out the Perl string length function to do more with strings.