J
John
I have a text file test.txt:
<style>
a {font-size: 12px;font-family: Arial,Helvetica,sans-serif;}
</style>
I want to print the file with the following Perl program:
#!/usr/bin/perl
print "Content-Type: text/html; charset=iso-8859-1\n\n";
print '<html><head>';
print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
print '</head> <BODY>';
open MYFILE,"<test.txt";
$ii=1;
while ($myline=<MYFILE>)
{
print "The value is now $ii <br>"; # I expect to see "1" --> OK!
print "Line : ".$myline." was here<br>"; # I get "Line : was here"
print "Now it is $ii <br>"; # I get "Now it is 3
$ii=$ii+1;
}
close MYFILE;
print "</body> </HTML>";
Somehow the varaiable $ii changes value from 1 to 3 in the middle.
Is this a bug in Perl or what is going on? If I change the contents on the
test.txt to something else the problem goes away.
If the file test.txt has for example:
A quick fox
jumps over a fence
The end
...then no problem is evident..
<style>
a {font-size: 12px;font-family: Arial,Helvetica,sans-serif;}
</style>
I want to print the file with the following Perl program:
#!/usr/bin/perl
print "Content-Type: text/html; charset=iso-8859-1\n\n";
print '<html><head>';
print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
print '</head> <BODY>';
open MYFILE,"<test.txt";
$ii=1;
while ($myline=<MYFILE>)
{
print "The value is now $ii <br>"; # I expect to see "1" --> OK!
print "Line : ".$myline." was here<br>"; # I get "Line : was here"
print "Now it is $ii <br>"; # I get "Now it is 3
$ii=$ii+1;
}
close MYFILE;
print "</body> </HTML>";
Somehow the varaiable $ii changes value from 1 to 3 in the middle.
Is this a bug in Perl or what is going on? If I change the contents on the
test.txt to something else the problem goes away.
If the file test.txt has for example:
A quick fox
jumps over a fence
The end
...then no problem is evident..