cool_jr256 has asked for the wisdom of the Perl Monks concerning the following question:

Oh wise ones,
I require quick help...I need to change the first character in a string
to upper case.

How can this be accomplished other than splitting the string into seperate characters and then joining them after?

Thanks

Replies are listed 'Best First'.
Re: Replacing a character in a string
by duff (Parson) on Nov 15, 2005 at 21:02 UTC

      Working link: ucfirst

      ([doc://ucfirst], for future reference.)

Re: Replacing a character in a string
by chibiryuu (Beadle) on Nov 15, 2005 at 21:24 UTC
    Even if you didn't know about ucfirst, it's easy enough to do with quoting:

    "\u$_"

    Or with a regex, if you didn't know about that either, but that's weird.

    s/(.)/uc$1/e

        As long as we're getting silly ...

        $s &= ~' ';
        (Warning: may not work for non-7-bit-ASCII letters such as accented characters, Cyrillic characters, or anything in EBCDIC. Or even any characters that aren't actually letters. But it is fun to do.)