in reply to String Length

OK, this smells a bit like homework.

But even if it isn't, check length. But what you really want is a regular expression instead, or perhaps substr.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: String Length
by Anonymous Monk on Apr 04, 2001 at 23:27 UTC
    I think your suggestion may work. I guess the best way to approach this problem would be to get the length and if the length = 3 then use chomp and then substring the numeric charcter out of the string and pass it to a variable. Then the same would hold true for other similar situations?? TIA- ep
      actually, you should use chop twice. chomp only eats end of line characters (default are "\r\n"). chop eats whatever is there. Although I really think you should use a regexp instead, in case the last couple characters aren't "ST".
        What if I'm looking for "ST" or "TH" or "RD"? How would a regular expression help in this instance? ep