Perl (Scripting) - Upper case (uc)

by
Jeremy Canfield |
Updated: March 09 2020
| Perl (Scripting) articles
In this example, the $foo variable contains "Hello World".
my $foo = "Hello World";
The uc (upper case) operator can be used to update the value to be "HELLO WORLD".
$foo = uc($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