perl function ucfirst
www.igiftidea.com
The ucfirst
function in Perl is used to convert the first character of a string to uppercase. It takes a single argument which is the string to be modified, and returns a new string with the first character converted to uppercase.
Here's an example:
my $str = "the quick brown fox jumps over the lazy dog"; my $new_str = ucfirst($str); print "$new_str\n";
Output:
The quick brown fox jumps over the lazy dog
In the example above, we first define a string $str
with all lowercase characters. We then call the ucfirst
function on this string, which returns a new string with the first character ("t") converted to uppercase ("T"). We store the result in a new variable $new_str
, and then print the modified string to the console.