FreeKB - Update a string to upper case in Perl (uc)
Update a string to upper case in Perl (uc)

Home > Search


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";
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments