in reply to Comparing lower to upper case

If you only need things to be the same case for the comparison, then you can use uc or lc to force your strings to be upper or lower.

if ( uc($str) eq uc($something) ) { # ... }

Alternately, and if you need care about the original case, you can reassign $str to an upper- or lowercased version of itself before you do anything else.

$str = uc($str); # force uppercase

    --k.


Replies are listed 'Best First'.
Re: Re: Comparing lower to upper case
by bobothesmart (Initiate) on Jun 11, 2002 at 18:57 UTC
    My statement looks like this:
    $fields[[0]] = uc($fields[[0]]);

    However, it does change this: 7f8954 into 7F8954.
    Id there a way to explicitely change just the one letter to uppercase?

    SORRY! It should say that it does NOT convert 7f8954 to 7F8954
      However, it does change this: 7f8954 into 7F8954.
      What? I thought that's what you wanted it to do...

      SORRY! It should say that it does NOT convert 7f8954 to 7F8954
      I'm confused now. You mean $fields[0] = uc($fields[0]); isn't converting 7f8954 to 7F8954?

      $fields[0] = "7f8954"; $fields[0] = uc($fields[0]);

      $fields[0] should now have a value of "7F8954"

      $fields[0] =~ tr/a-z/A-Z/; will also work.

      Joshua