Thank you for all your gentle answers, but if I run this:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
srand();
$fil="ch";
open(OUT, '>>'.$fil);
for($i=1;$i<10001;$i++){
$j=int(rand(20000))+440000;
$k=substr(pack('l>',$j),1);
print OUT $k;
}
close(OUT);
print "DONE !";
it produces one file with a variable length, but always greater than 30000 characters (for exemple 30045) !
So I suppose something is wrong in the pack line coding... | [reply] [d/l] |
| [reply] [d/l] [select] |
Hi BrowserUk,
Many thanks for your pertinent remarks and sorry for my bad code formatting, especially from a guy whose his father was a French cooking chief :-)
In fact I append many integer values thus the ">>". And they could be negative, because they are latitudes and longitudes worldwide.
I was also using the old fashioned format in the "for" loop...
But despite using the "binmode" instruction, the resulting file is longer than 30000 chars for 10000 iterations, typically 30035 !!!
Please, do you have any idea for this strange behaviour ?
| [reply] |
It was /256. Just misremembered cause I changed comps in the middle.
| [reply] |
| [reply] |