in reply to Unix \n vs. DOS \n
chomp will only remove the last character if it's a newline. Consider the following "harmless" code:
You can't see it in the above code, but I deliberately did not hit "Enter" after the last line. I even hit backspace a few times to ensure that there was nothing after the word "another". The result?#!/usr/bin/perl -w use strict; while (<DATA>) { chop; print "$_\n"; } __DATA__ this is a test this is another
chop happily removed the "r" in another. chomp was designed for situations like that and should be used where appropriate.this is a test this is anothe
Cheers,
Ovid
|
|---|