- Original Message -
From: $Bill Luebkert [EMAIL PROTECTED]
I *have* had runs of 50 32's, but often there's a sprinkling of 33's
throughout. (Try about 500 iterations and there should be at least one
33 ).
I'm not seeing that.
Wonder why that is ? Are you running the code for 'try.pl' as I originally
posted ? (From what you posted it looks like you are.)
Here is one that outputs 1000 lines to a file
and then when you give it an arg, it checks the lines in the file.
I get no lines with other than 33 chars. I added a newline and
prevented embedded newlines just for the test - making each line 33.
use strict;
if (@ARGV) {
open IN, 'out.txt';
binmode IN;
while (IN) {
my $len = length $_;
print $len, \n if $len != 33;
}
close IN;
exit;
}
open OUT, out.txt or die;
binmode OUT;
for (1 .. 1000) {
my @try = ();
while (scalar (@try) 256) {
push @try, int rand (2);
}
my $vector = join '', @try;
my $pack = pack 'b*', $vector;
if (length ($pack) != 32) {
print ERROR\n;
} else {
$pack =~ s/\x0A/\*/g; # \n = '*' to prevent short lines
print OUT $pack, \n;
}
}
close OUT;
__END__
I'll try that out - though implementation of the idea relies on an
alteration to 'try.pl' (which means it's outside the terms of reference :-)
Thanks for the 'O_BINARY' reference. I did a google search for it and turned
up some code that looks like it should be binmoding stdout - judging by the
comments attached to the code and the fact that it compiles ok. I'm still
not always catching the expected number of bits - but I really don't know if
that's because stdout is *not* binmoded, or because of some bug in the code.
The executable is not behaving as it should - which is what got me curious
in the first place.
The lesson is:
*never* try to probe C code when the tailor-made print function that comes
with its library won't even work. (It gave Dr.Watson quite a workout.)
Cheers,
Rob
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs