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

hi i would like to know how to convert a string to uppercase letters. For example

my $string = "I_NEED_(HELP)";

I would like to convert it to "I_need_help", i know to convert uppercase letter a code would be $string =~ s/([^_]+)/\u\L$1/g; But how i can't seemed to convert the HELP.

Code tags and formatting added by davido.

Replies are listed 'Best First'.
Re: How do i convert uppercase in a bracket.
by Animator (Hermit) on May 06, 2005 at 12:54 UTC
    $string = ucfirst lc $string; $string =~ tr/()//d;
      Sorry i just read i posted the wrong thing. I wanted I_Need_Help instead how do i do that?
        $string =~ s/([a-z]+)/ucfirst(lc($1))/ieg;
        would give you 'I_Need_(Help)'
        I'm sure you can strip the brackets for yourself...

        as an aside, when posting code it should be inside <code></code> tags, I guess you had a character class in your original regex, which has been garbled by the perlmonk's own-brand markup.

        ---
        my name's not Keith, and I'm not reasonable.

        perldoc -f split, perldoc -f map, perldoc -f lcfirst, perldoc -f join.