in reply to "Chop" problems

  1. chop returns the character choped off, so if you expect it to print "fred" it won't.
  2. chop "$a" isn't the same thing as chop $a. You have to pass a variable to chop, so it can modify it -- what you are passing it is a string constant that you made which contains the variable.

Replies are listed 'Best First'.
Re: Re: "Chop" problems
by thor (Priest) on Oct 12, 2002 at 14:06 UTC
    Good point, hossman. The original poster could have seen this had he used -w in his invocation of perl. I just tried it, and got this error:

    Can't modify constant item in chop at test.pl line 2, near ""foo";"

    thor

A reply falls below the community's threshold of quality. You may see it by logging in.