There is a function ucwords() in PHP which capitalizes the first letter of each word. PHP: <? $str = "programming forums"; $str = ucwords($str); // now $str = "Programming Forums" ?> I have written a sub-routine in Perl, which gives the same functionality. Code: sub ucwords { $str = shift; $str = lc($str); $str =~ s/\b(\w)/\u$1/g; return $str; } $str = "programming forums"; $str = &ucwords($str); # now $str = "Programming Forums"