Perl (Scripting) - Lower case (lc)

by
Jeremy Canfield |
Updated: August 18 2020
| Perl (Scripting) articles
In this example, the $foo variable contains "Hello World".
my $foo = "Hello World";
The lc (lower case) operator can be used to update the value to be "hello world".
$foo = lc($foo);
In a regular expression, the i operator can be used to ignore case in a comparison. In this example, the comparison operator checks if the $foo variable contains the text "hello", regarless of the case sensitivity of the value in the $foo variable.
if ($foo =~ /hello/i) {
 print "foo contains hello\n";
}
Did you find this article helpful?
If so, consider buying me a coffee over at