How to manipulate the cases of letters in a string?

Discussion in 'Perl Misc' started by xz, Oct 5, 2007.

  1. xz

    xz Guest

    Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love this
    game"

    ?
    xz, Oct 5, 2007
    #1
    1. Advertising

  2. xz

    Paul Lalli Guest

    On Oct 4, 7:47 pm, xz <> wrote:
    > Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love this
    > game"


    Jim has already given you the answer, so just some extra
    information... You may not be aware of this, but you can get a listing
    of ALL Perl functions, ordered by category, by typing this at your
    command prompt:

    perldoc perlfunc

    If you do that, you will see, for example:
    Functions for SCALARs or strings
    "chomp", "chop", "chr", "crypt", "hex", "index", "lc",
    "lcfirst", "length", "oct", "ord", "pack", "q/STRING/",
    "qq/STRING/", "reverse", "rindex", "sprintf", "substr",
    "tr///", "uc", "ucfirst", "y///"

    Perhaps not the most helpful in this case, as it may not be intuitive
    that "lc" stands for "lowercase", but it's still good to know in
    general.

    Paul Lalli
    Paul Lalli, Oct 5, 2007
    #2
    1. Advertising

  3. xz

    Greg Bacon Guest

    In article <>,
    xz <> wrote:

    : Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love this
    : game"

    $ cat try
    #! /usr/bin/perl

    $_ = "i LOVE this Game";

    print "\U$_\n",
    "\L$_\n";

    $ ./try
    I LOVE THIS GAME
    i love this game

    Hope this helps,
    Greg
    --
    When asked by the king what he thought he was doing by infesting the sea, he
    replied with noble insolence, "What do you think you are doing by infesting
    the whole world? Because I do it with one puny boat, I am called a pirate;
    because you do it with a great fleet, you are called an emperor." --Augustine
    Greg Bacon, Oct 5, 2007
    #3
  4. Petr Vileta wrote:
    > Jim Gibson wrote:
    >> In article <>, xz
    >> <> wrote:
    >>
    >>> Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love
    >>> this game"

    >>
    >> perldoc -f uc
    >> perldoc -f lc

    >
    > Your answer is short and to the subject, but not all perl programmers
    > use Linux. I can mention only that some of us are using ActiveState Perl
    > and we have not any perldoc.exe on our Windows PCs :)


    We have perldoc.bat on our system in the \perl\bin directory.
    And we have also the HTML documentation under \perl\html.
    Simply open the index.html, in the left frame search for perlfunc, klick
    it and search for upper.


    > Maybe will be better to write some "OS independent", e.g. "look at
    > function uc()".
    > I don't know what type of documentation is on Mac.


    I think the same as on Win. or Unix: perldoc and/or the HTML documentation.

    regards,
    Reinhard

    --
    Reinhard Pagitsch, Oct 5, 2007
    #4
  5. xz

    xz Guest

    On Oct 5, 3:15 am, Reinhard Pagitsch <> wrote:
    > Petr Vileta wrote:
    > > Jim Gibson wrote:
    > >> In article <>, xz
    > >> <> wrote:

    >
    > >>> Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love
    > >>> this game"

    >
    > >> perldoc -f uc
    > >> perldoc -f lc

    >
    > > Your answer is short and to the subject, but not all perl programmers
    > > use Linux. I can mention only that some of us are using ActiveState Perl
    > > and we have not any perldoc.exe on our Windows PCs :)

    >


    > We have perldoc.bat on our system in the \perl\bin directory.
    > And we have also the HTML documentation under \perl\html.

    Do you know where is this html documentation on linux?
    Thanks!

    > Simply open the index.html, in the left frame search for perlfunc, klick
    > it and search for upper.
    >
    > > Maybe will be better to write some "OS independent", e.g. "look at
    > > function uc()".
    > > I don't know what type of documentation is on Mac.

    >
    > I think the same as on Win. or Unix: perldoc and/or the HTML documentation.
    >
    > regards,
    > Reinhard
    >
    > --
    xz, Oct 5, 2007
    #5
  6. xz

    xz Guest

    On Oct 5, 10:50 am, xz <> wrote:
    > On Oct 5, 3:15 am, Reinhard Pagitsch <> wrote:
    >
    >
    >
    > > Petr Vileta wrote:
    > > > Jim Gibson wrote:
    > > >> In article <>, xz
    > > >> <> wrote:

    >
    > > >>> Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love
    > > >>> this game"

    >
    > > >> perldoc -f uc
    > > >> perldoc -f lc

    >
    > > > Your answer is short and to the subject, but not all perl programmers
    > > > use Linux. I can mention only that some of us are using ActiveState Perl
    > > > and we have not any perldoc.exe on our Windows PCs :)

    >
    > > We have perldoc.bat on our system in the \perl\bin directory.
    > > And we have also the HTML documentation under \perl\html.

    >




    > Do you know where is this html documentation on linux?
    > Thanks!

    Just figured out this..... thank you guys.

    >
    > > Simply open the index.html, in the left frame search for perlfunc, klick
    > > it and search for upper.

    >
    > > > Maybe will be better to write some "OS independent", e.g. "look at
    > > > function uc()".
    > > > I don't know what type of documentation is on Mac.

    >
    > > I think the same as on Win. or Unix: perldoc and/or the HTML documentation.

    >
    > > regards,
    > > Reinhard

    >
    > > --
    xz, Oct 5, 2007
    #6
  7. xz <> wrote:
    > On Oct 5, 3:15 am, Reinhard Pagitsch <> wrote:
    >> Petr Vileta wrote:


    >> And we have also the HTML documentation under \perl\html.


    > Do you know where is this html documentation on linux?



    perldoc pod2html


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad McClellan, Oct 6, 2007
    #7
  8. "Petr Vileta" <> wrote in
    news:fe4fgi$1623$:

    > Jim Gibson wrote:
    >> In article <>, xz
    >> <> wrote:
    >>
    >>> Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love
    >>> this game"

    >>
    >> perldoc -f uc
    >> perldoc -f lc

    >
    > Your answer is short and to the subject, but not all perl programmers
    > use Linux. I can mention only that some of us are using ActiveState
    > Perl and we have not any perldoc.exe on our Windows PCs :)


    C:\DOCUME~1\asu1\LOCALS~1\Temp> perldoc -f uc
    uc EXPR
    uc
    Returns an uppercased version of EXPR. This is the internal
    function implementing the "\U" escape in double-quoted strings.
    Respects current LC_CTYPE locale if "use locale" in force. See
    perllocale and perlunicode for more details about locale and
    Unicode support. It does not attempt to do titlecase mapping on
    initial letters. See "ucfirst" for that.

    If EXPR is omitted, uses $_.

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)
    clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>
    A. Sinan Unur, Oct 18, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    1
    Views:
    313
    Mike Wahler
    Jan 22, 2005
  2. chessc4c6

    Manipulate String

    chessc4c6, Apr 8, 2005, in forum: C++
    Replies:
    1
    Views:
    334
    Marc Aguilera
    Apr 9, 2005
  3. Chris

    manipulate string

    Chris, Oct 28, 2003, in forum: Python
    Replies:
    14
    Views:
    519
    Michel Claveau/Hamster
    Oct 28, 2003
  4. Merrigan
    Replies:
    4
    Views:
    557
    Chris
    Dec 14, 2007
  5. Venugopal
    Replies:
    11
    Views:
    1,495
    Tassilo v. Parseval
    Nov 5, 2003
Loading...

Share This Page