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.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.