Perl ucfirst Function

These sites are FOR SALE: miscperlinfo.com, mpihowto.com!
If you are interested, please use my Contact page.




The Perl ucfirst function takes a string, converts its first character in uppercase and than returns the new string.

The syntax forms of the ucfirst function are as follows:

ucfirst EXPR
ucfirst

It returns the value of EXPR with its first character in uppercase.

If the argument is a string variable, this function returns the variable with its first character uppercase, but it doesn’t alter the content of the variable.


Click Below to See the Best

Perl How-to Snippet Collection

and Save Hours of Surfing on Internet!

In the second syntax form, EXPR is omitted, so the Perl ucfirst function uses the special variable $_. As with other functions, you can use or omit the parentheses, as you like.

If the first letter of the string expression is uppercase, the function will do nothing.

The following simple example shows you how to convert the first character of a string in uppercase, using the ucfirst function:

# initialize a string variable
my $str = "an example about ucfirst function";
my $newStr = ucfirst $str;

print "$newStr\n";
# it prints: An example about ucfirst function


A-N-Y-O-N-E Can Learn and Master Perl!
And That Includes YOU!


Check these how-to tutorial eBooks (PDF format):


Table of Contents:

A Perl Script
Install Perl
Running Perl
Perl Data Types
Perl Variables
Perl Operators
Perl Lists
Perl Arrays
    Array Size
    Array Length
Perl Hashes
Perl Statements
    Perl if
    Perl unless
    Perl switch
    Perl while
    Perl do-while
    Perl until
    Perl do-until
    Perl for
    Perl foreach
Built-in Perl Functions
    Functions by Category
        String Functions
        List Functions
        Array Functions
        Hash Functions
        Miscellaneous Functions
    Functions in alphabetical order
        chomp
        chop
        chr
        crypt
        defined
        delete
        each
        exists
        grep
        hex
        index
        join
        keys
        lc
        lcfirst
        length
        map
        oct
        ord
        pack
        pop
        push
        q
        qq
        qw
        reverse
        rindex
        scalar
        shift
        sort
        splice
        split
        sprintf
        substr
        tr
        uc
        ucfirst (more)
        undef
        unpack
        unshift
        values

return from Perl ucfirst function to Perl Basics



Would you like to create your own website like this one?
Hit the Alarm Clock!

Site Build It!