Hi. Please read Site How To before you submit code next time and save the editors and yourself a lot of work. Thanks.
I just appended the data lines from above to the end of the code I gave you at pulling by regex and it parsed it correctly.
Ouput
Then I looked at your version of the code and noticed this:
open LOGFILE, "datafile.html" || die "Can't open file";
The problem with this line is that because you are not using brackets around the parameters to open combined with the relatively high presedence of ||, this is being parsed as
open( LOGFILE, ("datafile.html" || die "Can't open file") );
which as the first part of the || statement is always true, the second part ('die die "Can't open file"') is simply being optimised away meaning that even if the open fails (because input file does not exist or is not in the current subdirectory etc), you will never see any error msg. Could this be your problem?
The fix is to use either
open(LOGFILE, "datafile.html") || die "Can't open file$!";
or
open LOGFILE, "datafile.html" or die "Can't open file$!"
Please also note the inclusion of $! in the error message. This will tell you why the open failed if it does, not just if. See Error Indicators for further details.
The second thing I noted was the name of the file: "datafile.html"?? If this is a logfile, why is it named .html? If the file conatains html tags, the regex supplied will not parse the data.
Your not by any chance viewing and saving the logs via a web interface are you? If so, you need to cut&paste from the screen to a file or use "Save as...type *.txt" if your browser has that option in order to remove the html tags from the file.
If that doesn't explain and allow you to fix the problem come back and post the error message or otherwise describe what you are seeing (eg. No output, wrong output, etc).
No need to re-post the code or data again unless it has changed substantially.
Good luck.
Examine what is said, not who speaks. |