> -----Original Message-----
> Behalf Of Morse, Richard E.
>
> Hah!  I know what the problem is!
>
> ASCII character 10 happens to be either \n -- so when you print
> this number to
> the file, you get a newline character for one of the bytes, so your
> while(<READ>) loop finds three lines in the file instead of two.
>
> I think that in order to read this number back out of the file,
> you'll have to
> use sysread, instead of <READ>...
>

In addition to the above you might want to look at why you would want a '\n'
in the file at all.  That is useful in a human readable file, but the file
you will end up with will not be readable.  And if you are looking for an
end of data marker I don't think a single character (or two for win32) is
going to be sufficient.  Either 0x0000 or 0xffff are probably better choices
(or the 4 byte versions of each.)

>
> -----Original Message-----
> From: Sisyphus [mailto:[EMAIL PROTECTED]]
>
> Hi,
>
> Ok - so I'm running the code below and it's working as I want - unless
> either of the 2 values being written to the file is 10. (ie
> unless $num = 8
> or 10).
>
> If the value is 10, then I get a couple of warnings about 'use of
> uninitialised value'.
> '10' is the only value I've found that exhibits this disgraceful
> behaviour.
>
> Ummmm ...... I'm a little hard pressed to make sense of that ........
> something to do with the newline characters or the chomping perhaps ?
>
> use warnings;
> my $file = "try";
> my $num = 111111112;
> open (WRITEB, ">$file")
>         or die "Can't open WRITEB: $!";
> binmode WRITEB;
> print WRITEB pack("I",$num,), "\n";
> print WRITEB pack("I",$num + 2), "\n";
> close (WRITEB)
>          or die "Can't close WRITEB: $!";
>
> open (READ, "$file")
>         or die "Can't open READ: $!";
> binmode READ;
> while (<READ>) {
> chomp;
> $ret = unpack("I", $_);
> print $ret, "\n";
> }
> close (READ)
>          or die "Can't close READ: $!";
>

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to