in reply to Re: Re: String Length
in thread String Length

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".

Replies are listed 'Best First'.
Re: Re: Re: Re: String Length
by Anonymous Monk on Apr 04, 2001 at 23:39 UTC
    What if I'm looking for "ST" or "TH" or "RD"? How would a regular expression help in this instance? ep
      This is crossing the line between our helping out and our doing your homework for you. Read perlre.

      (Aimed that the Anonymous Monk, not ep.)

      $string =~ s/(.*).{2}$/$1/;
      will take ANY two characters off of the end of the string.

      my $name = 'Ben Kittrell'; $name=~s/^(.+)\s(.).+$/\L$1$2/g; my $nick = 'tha' . $name . 'sta';