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

I am writing a program to take filenames and turn them into other things (an index of accounts, hyperlinks for the accounting department, etc.) and some users would like to see capital letters in the names. For example I have turned "jackson_corp.xls" into "jackson corp." and they want "Jackson Corp." Anyone got any idea how to do this?

Replies are listed 'Best First'.
Re: capitalization question
by Plankton (Vicar) on Mar 26, 2004 at 21:36 UTC
    Take a look at ucfirst

    Plankton: 1% Evil, 99% Hot Gas.
      #!/usr/bin/perl use strict; while(<DATA>) { print map ( ucfirst($_) . " ", split / / ); } __DATA__ jackson corp

      Plankton: 1% Evil, 99% Hot Gas.
Re: capitalization question
by bageler (Hermit) on Mar 26, 2004 at 23:06 UTC
    i use a lot of
    $foo = ucfirst lc $foo;
    this takes care of cases where there are stray uppercase letters, or the original word is all uppercase to begin with
Re: capitalization question
by Cody Pendant (Prior) on Mar 27, 2004 at 04:07 UTC
    What should happen if one of the businesses involved is called "The USB specialists" or "The MGM Grand" or "The FBI"?


    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
    =~y~b-v~a-z~s; print
Re: capitalization question
by pbeckingham (Parson) on Mar 27, 2004 at 01:41 UTC

    Triy this:

    my $s = 'jackson corp.'; $s = join ' ', map {ucfirst lc} split ' ', $s; print $s, "\n";

A reply falls below the community's threshold of quality. You may see it by logging in.