in reply to SOLVED Removing characters

tr modifies the string it works on, and returns the number of substitutions.

BTW when you want to join two strings, use a dot ., not a plus +. (This is called "concatenation").

Replies are listed 'Best First'.
Re^2: Removing characters
by Slug (Acolyte) on Jan 22, 2008 at 14:34 UTC
    Doh! Thanks. Back to the drawing board :(
Re^2: Removing characters
by Slug (Acolyte) on Jan 22, 2008 at 14:52 UTC
    What should I be using instead of TR?
      You can use tr, but you have to discard its return value.
      my $str = "ab c,d.e"; $str =~ tr/ ,.//; # here $str is "abcde"
      So you need to use the modified string after the tr. And don't try to stuff it all in one line ;-)

      (Update: fixed match operator)