<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
This is puzzling. For me, the script behaves exactly as it ought,
even on Windows. Even if I change the script to use UNIX line
terminators, it behaves as it ought. And (see following script) even
when I add in a binmode() call to turn off Perl/Windows automatic
conversion of \cM\cJ to \n, it still behaves just as predicted. <br>
<br>
I may be missing something, but it looks like there may be some
oddity in the DATA file handle. I copied the data to a separate
file, and modified the script, leaving in the binmode. Now, the same
data is in the DATA file handle, and in both cases I used the
Windows line terminations. Now, if I check the byte-level output
(with "perl test.pl | od -c"), I get different behaviour with versus
without the open call, which ought to read the same data. <br>
<br>
In effect, binmode(DATA, ':raw') has no effect on the inline DATA
block. This suggests maybe there are some unusual effects specific
to the DATA filehandle. This wouldn't account for what you see, but
certainly I'd test it reading from a regular filehandle for
comparison. What version/build of Perl are you using?<br>
<br>
All the best<br>
Stuart<br>
<br>
<small><tt># Modified script to play with DATA filehandles<br>
use warnings;<br>
use strict;<br>
<br>
open(DATA, "<", "data.txt"); # comment out this line, to
compare with it included<br>
<br>
#binmode(\*DATA, ':raw'); # turn off \cM\cJ => \n on read,
has no effect without open() call<br>
<br>
while (<DATA>) {<br>
chomp $_;<br>
print "$_";<br>
}<br>
<br>
__END__<br>
a<br>
b<br>
c<br>
d<br>
e<br>
f<br>
g<br>
h</tt></small><br>
<br>
<br>
On 04/02/2011 3:42 PM, Omid Gulban wrote:
<blockquote cite="mid:358597.46621.qm@web65407.mail.ac4.yahoo.com"
type="cite">
<style type="text/css"><!-- DIV {margin:0px;} --></style>
<div style="font-family: times new roman,new york,times,serif;
font-size: 12pt;">
<div><font><font size="2">Hello All,<br>
<br>
I have a simple script shown below:<br>
on windows xp platform.<br>
<br>
</font></font></div>
</div>
</blockquote>
...<br>
<blockquote cite="mid:358597.46621.qm@web65407.mail.ac4.yahoo.com"
type="cite">
<div style="font-family: times new roman,new york,times,serif;
font-size: 12pt;">
<div><font><font size="2">
Why do I get an output that looks like this:<br>
a<br>
ab<br>
bc<br>
cd<br>
de<br>
ef<br>
fg<br>
ghh<br>
</font></font></div>
</div>
</blockquote>
</body>
</html>