perl function lc
www.igiftidea.com
The lc
function in Perl is used to convert a string to lowercase. It takes a single argument, which is the string to be converted, and returns the lowercase version of that string.
Here's an example that demonstrates how to use lc
:
#!/usr/bin/perl use strict; use warnings; # Define a string my $string = "HELLO WORLD"; # Convert the string to lowercase my $lowercase = lc($string); # Print the original and lowercase strings print "Original string: $string\n"; print "Lowercase string: $lowercase\n";
In this example, we start by defining a string called "HELLO WORLD". We then use the lc
function to convert the string to lowercase and store the result in a new variable called $lowercase
. Finally, we print both the original and lowercase versions of the string to the console.
When we run this script, we see that the original string is printed in all uppercase letters, while the lowercase version of the string is printed in all lowercase letters:
Original string: HELLO WORLD Lowercase string: hello world