>>   Maintainer: Nathan Torkington <[EMAIL PROTECTED]>
>>   Date: 5 Sep 2000
>>   Last Modified: 15 Sep 2000
>>   Mailing List: [EMAIL PROTECTED]
>>   Number: 195
>>   Version: 2
>>   Status: Frozen

>As I mailed to Nathan Torkington several days ago (without getting 
>a reply), many people use chop() a lot and his perl526 substitute
>"s/.\z//s;" will not work because it returns the number of
>chars changed, not the char itself like chop() does (as opposed to
>chomp()).

This:

    $char = chop $var;

is the same as:

    $char = substr($var, -1, 1, '')

I find the former to be easier to read and write, and so, to maintain.

The general problem with chop/chomp may not have been explained yet.
It's that they need lvalues because they're mutators that change
their arguments.  This is confusing.  It does not follow (in the normal
case) the standard notation of:

    $y = fn($x);

such as

    $char_count  = length($string);
    $hex_version = hex($string);
    $nonfraction = int($number);

and so and so forth.    *That's* how people most expect functions to 
work, and when a few of them don't, this confuses them.  That's
what we get people wanting to do

    $line_sans_terminator = chomp <FH>;

or 

    $last_list_element = pop some_func();

--tom

Reply via email to