I'm trying to print to the top of an HTML file how many unique visitors the page has gotten. However, the variable does not get defined until later in the script. See below.
# CSC 310 Project # 4 #opening log and html file open (LOG, '<', 'IN-access.log'); open (HTML, '>>', 'OUT-access.html'); #printing header/title/format of html print HTML "<HTML><TITLE>Visitors Log</TITLE><BODY>\n"; print HTML "The log file start date is: date() <BR>\n"; print HTML "There were $IPcount unique visitors in the logfile.<BR>\n" +; print HTML "There were 2 visits yesterday<BR>\n"; print HTML "<TABLE border=1><TR><TD>IP</TD><TD>LOGFILE</TD></TR>\n"; #reading log file while ($lines = <LOG>){ #keeps track of unique visitors $oldIP = $remoteIP; #assigning values ($remoteIP,$rfc,$userID,$dateTime,$timeZone,$requestType,$fileRequ +ested,$requestProtocol,$statusCode,$sizeOfFile) = split ' ', $lines; #keeps track of unique visitors if ($oldIP ne $remoteIP){ $IPcount += 1; } ....
The variable $IPcount is blank when printed into the HTML file but I was wondering if there's a way to get the value to print even though it wasn't defined until later on.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |