On Wed, 30 Aug 2000 16:14:35 -0600, Tom Christiansen wrote:

>>I say we drop chop().
>
>So code that says
>
>    chop($k,$v)
>
>will need to say
>
>    for ($k,$v) { s/.\z//s } 
>
>or else something like:
>
>    for ($k, $v) { substr($_, length() - 1) = '' }
>
>I'm not sure I find either of those more legible.

I'm sure. It's not. But either of this works.

        substr($_, -1) = '';

        $chopped = substr $_, -1, 1, '';

chop() is a speed optimization for a (currently) pretty uncommon task:
removing the last character of a string. Why not the first character,
for example? The string equivalent of shift()?

Only people who insist that ALL lines in a text file should end in a
newline, would still prefer use it.

-- 
        Bart.

Reply via email to