in reply to When do you use chop instead of chomp?

I guess an appropriate place to use it would be when reading from STDIN when you are reasonably sure it is line terminated.
print "Enter a url!:\n"; my $url = <STDIN>; chop($url);
In practice I NEVER use chop. Even though chomp is slower, I feel that with chop it's a lot easier to introduce subtle bugs. (Let's say you cut and paste a block of code.)

-Lee

"To be civilized is to deny one's nature."

Replies are listed 'Best First'.
Re^2: When do you use chop insetad of chomp?
by particle (Vicar) on Mar 03, 2002 at 06:05 UTC
    i use chop to rotate.

    my $val = 123; $val = chop($val) . $val; print $val; # prints '312' my $val = 'abc'; $val = chop($val) . $val; print $val; # prints 'cab'

    ~Particle ;Þ

      Pretty cool. Never would have ocurred to me. One of the things I love about Perl (besides making my life so much easier) is that even though I've used it every day for a few years there is still always something more to learn and one more way to do something..

      -Lee

      "To be civilized is to deny one's nature."