From: Larry G. <List@ISComp.com> - 2003-12-24 17:11:11
|
Hi Jamie, Thanks for the response and help! > -----Original Message----- > From: Jamie Cameron > > Larry Gilson wrote: > > I hope I can both articulate the problem and that this is > > just something I am overlooking. > > I have a report library for a module. In a specific section, > > it parses /var/log looking for maillog*. I have no problem > > accessing the files and reading them. However, after copying the > > > file to an array, the arrayappears to have no input record > > separators. The foreach control structure > > You can read a whole file into an array with code like : > > open(FILE, $file); > @lines = <FILE>; > close(FILE); Yes, that is essentially what I do: foreach $file (@files) { open (FH, "$path/$file"); @wholefile = <FH>; close(FH); The file is read without a problem. When it comes to iterating through the file though, it only makes one pass. I have also attached output so you can see the problem. I actually forced it to read my custom procmaillog and I do not see the same problem. While I get 0 for output, it reads each line of the file. For some reason, reading maillog with 'foreach $line (@wholefile) { }' only makes one pass when run _within_ reports-lib.pl. It is like the entire file was read into one array element. However when mail-stats.pl, is run from reports-lib.pl with the following code, it works fine. $mailstats = `/usr/libexec/webmin/merlin/mail-stats.pl`; print $mailstats; > > that should iterate through each line of the log only makes one > > pass. The odd thing is that I can take the exact script, make it > > stand alone and use a print statement that utilizing backtick > > assignment from the same locationand it will iterate through the > > file and provide the appropriate output. Additionally, I can > > call the stand alone script from the shell and it provides the > > appropriate output. I am not using any external modules. > > This simply opens the file, parses it, does some math, and > > > > outputs the result. Am I doing something wrong? Can anyone help > > me with this? > > Would it be possible for you to post the actual code to the list? > Or at least the segment that is having trouble .. That would make > it easier to track down the problem. Most definitely. Please see the attached. P.S. If you are wondering why the high scan times, I forgot to remove Osirusoft and Orbs checks in SA after I recompiled and updated. Doh! Happy Holidays! Regards, Larry |