What version of Perl are you using, and what kind of line breaks does the input file text.txt contain (Unix, Mac or other)? I have perl 5.10.1 on Windows XP (ActivePerl distribution), and it has no problem recognizing Unix line breaks, but I have not tested it with Mac line breaks).