On Sat, Jan 27, 2001 at 03:42:43PM -0700, root wrote:
> I read RFC195 suggesting to drop 'chop' and go with 'chomp'.
> What does 'chop' have anything to do with 'chomp'?

chop() and chomp() are very often confused due to their similar names,
similar functionality and the fact that chop() did chomp()'s job
(poorly) prior to perl5.  Nowdays, chop() is very often used where
they really ment chomp().

Actually, the docs are somewhat to blame for this.  perlfunc is loaded
with chop misuses.  Will fix.

The complex nature of the complete chop() is unfortunate, it makes it
very difficult to reimplement and prototype.  The basic version,
however, isn't hard:

    sub chop (;\$) {
        my($var) = @_ ? $_[0] : $_;
        return substr($var, -1, 1, '');
    }

Once you start getting into chopping lists and hashes, it becomes
impossible to prototype.


PS I just ran exactly into your example the other day dealing with
Text::Wrap guts.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
BOFH excuse #69:

knot in cables caused data stream to become twisted and kinked

Reply via email to