On Wed, Mar 05, 2003 at 12:59:28PM -0800, Morgan Delagrange wrote:
> 
> --- Alex Chaffee / Purple Technology <[EMAIL PROTECTED]>
> 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. 

I admit I'm always confused about these details, so let's ask Perl:

[EMAIL PROTECTED] jakarta-commons]$ perl -e '$x = "foo"; chomp($x); print $x;'
[EMAIL PROTECTED] jakarta-commons]$ perl -e '$x = "foo\n"; chomp($x); print $x;'
[EMAIL PROTECTED] jakarta-commons]$ perl -e '$x = "foo\n\n\n\n"; chomp($x); print $x
foo


[EMAIL PROTECTED] jakarta-commons]$

So it looks like it only chomps one separator, not all.

Perl also seems to glom \r\n; furthermore, I think that's the natural
expectation in the platform-independent world of Java.

-- 
Alex Chaffee                               mailto:[EMAIL PROTECTED]
Purple Technology - Code and Consulting    http://www.purpletech.com/
jGuru - Java News and FAQs                 http://www.jguru.com/alex/
Gamelan - the Original Java site           http://www.gamelan.com/
Stinky - Art and Angst                     http://www.stinky.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to