Tom Christiansen writes:
> 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 don't think chop() is an operation that's done often enough for
either of the things above to be a problem.

> I'm not sure I find either of those more legible.  And they certainly
> won't be faster.  chop() has been around since perl1, too.

Yes, but chop()'s original purpose was what chomp() is now used for.
I doubt Larry would really have put in a function to remove the last
char in a string just to have a function that removes the last char in
a string.  It was the chomp()-like itch I think he was trying to
scratch.

> Then again, yes, people do tend to use it when they oughtn't.  Hm...

Exactly.

Nat

Reply via email to