danield writes: > Hello all, > > I am looking for help with creating a digest of a log file. I have found > a nice tutorial that should help on > http://www.pageresource.com/cgirec/ptut14.htm. However, this tutorial > expects to have values in list separated by | : > > he Rock|Cheer|Rock Bottom > Triple H|Boo|Pedigree > Stone Cold|Cheer|Stone Cold Stunner > > And I do have a log file, that looks like: > > ... > Format count > a 100 > b 51 > c 130 > d 5 > e 6 > Total: --- > 292 > ... > > And I need to go through that log and find that 292 and store it into variable. > If it was something like 'total: 292', I might be able to do it, however the value > is on completely new line and nothing precedes it. > > Is anyone willing to help me? > > I am a completely newbie in programming. > > Thank you for your time. > > danield
This is a very typical situation. You need to read each line of the log file in a loop, and when you see the line with "Total:" as its first field, set a flag. Then when you go thru the loop again, you test the flag to see if it is set. If it is, you extract the interesting data from the line you just now read. You may also want to reset the flag, depending on whether you wish to do anything else after this with the input file. The above logic is very awk-like; an even cleaner way is to write a little subroutine to read the line, and call that in a loop, testing for the "Total:" in field one. When you see it, call the read line routine again and extract the interesting data. This way, you do not need to use any flags. Flags are messy and old fashioned. It is far better to use the program counter instead of flags to keep track of what you are doing. -- -------- "And there came a writing to him from Elijah" [2Ch 21:12] -------- R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 847 543-4060 Elijah Laboratories Inc. 457 Signal Lane, Grayslake IL 60030 fax 847 543-4061 ----- M o d e l i n g t h e M e t h o d s o f t h e M i n d ------ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>