commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morgan Delagrange <mdela...@yahoo.com>
Subject Re: [lang] chop and chomp
Date Wed, 05 Mar 2003 20:59:28 GMT

--- Alex Chaffee / Purple Technology <guru@stinky.com>
wrote:
> 
> Perl:
> 
> chop removes the final character, no matter what it
> is
> 
> chomp removes the final character if and only if
> it's a newline
> (or, technically, the $INPUT_RECORD_SEPARATOR).
> 

Technically, that's incorrect.  Perl's chomp command
deletes all consecutive substrings matching the
$INPUT_RECORD_SEPARATOR from the end of the string. 
Chomp returns the number of substrings deleted, while
chop returns the character deleted.  I believe that
Perl chop magic considers /r/n to be a single
character, but I'm not positive.

- Morgan

=====
Morgan Delagrange
http://jakarta.apache.org/taglibs
http://jakarta.apache.org/commons
http://axion.tigris.org
http://jakarta.apache.org/watchdog

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message