You need to change your file handle to binary mode to prevent the line ending transformations:
binmode(STDOUT); Please read `perldoc -f binmode`. Cheers, -Jan > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:perl-win32-users- > [EMAIL PROTECTED] On Behalf Of Bullock, Howard A. > Sent: December 27, 2007 8:25 AM > To: perl-win32-users@listserv.activestate.com > Subject: RE: Strange behavior with print > > I appear that perl's print command when using a file handle is changing > each occurrence of chr(10) to (chr(13) chr(10)). This does not seem to > be a helpful or proper action when working with defined literal strings. > > I can make some sense out of > file:///C:/Perl/html/lib/Pod/perlport.html#newlines but do see how that > is relevant to literal printing strings. > > [Bullock, Howard A.] > Sorry more info: > > I am using: Binary build 820 [274739] provided by ActiveState > http://www.ActiveState.com Built Jan 23 2007 15:57:46 > > ----------------------- > > I have a short program that extracts text file from a .gz archive using > Compress::ZLIB. > Using "while ($gz->gzreadline($line) > 0)" I read each line, potential > process it, then write the line to a new file. > > If print the length of $line it show a length of the text plus two > characters for 0D and 0A. > When I use: > > print "length=".length($line) ."\n"; > my @a = split //,$line; > foreach my $x (@a){ > print $x . " " . ord($x) ."\n"; > } > > I see exactly what I expect. > > However when I print the line to a file and view the file using two > different Hex editors, I see that the line terminates with "0D 0D 0A". I > am not using chomp, chop, or adding any characters to the variable > during the print. > > When I again use Perl to read the new file and use the sample code above > to analyze the input line, Perl again shows me the data I would expect > to see. That is a text line ending in just "0D 0A". > > When check the length of the input string it matches that number of what > was supplied to the print command. > > Is there some feature I am missing here or is this a bug? > _______________________________________________ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs