[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] HELP! Runaway file read!!!



Ok. I'm just not seeing what I'm doing wrong here.

The basic concept is, read in a Web log (MS IIS format :P ), and parse the
data. None of the reports relies on cross-referencing data, so I'm just
trying to separate it as I read it in.

What happens is that the script just keeps reading data in until I get an
"out of memory" error (even with MacPerl's memory partition set to 100+MB!)
(The sample log file I'm using for testing is maybe a few thousand lines).

I've included the problem code below. If anyone can see what I'm doing
wrong, I'd greatly appreciate the help.

Thanks,

Bryan

##############################################################################
#!/usr/bin/perl -w

use IO::File;

$handle = new IO::File "> computer-bay.html";

*STDOUT = $handle;		# Redirect STDOUT to FILEHANDLE.

$domain = "computer-bay.com";
$parsed_log = "computer-bay.log";

$logfile = new IO::File $parsed_log;	# Set up file handle object to log
file.

$count = 0;

# Suck in the whole file and push each field into array element/hash reference.

while($line = <$logfile>){

	chomp $line;

	($log{'rem_addr'}->[$count],
	$log{'uname'}->[$count],
	$log{'date'}->[$count],
	$log{'time'}->[$count],
	$log{'service'}->[$count],
	$log{'machine'}->[$count],
	$log{'proc_time'}->[$count],
	$log{'bytes_received'}->[$count],
	$log{'bytes_sent'}->[$count],
	$log{'result'}->[$count],
	$log{'method'}->[$count],
	$log{'file'}->[$count]) = split(/,/, $line);

	$count++;
}

****************************************
Bryan Patzke
milo@enteract.com
patzbry@iit.edu
http://www.enteract.com/~milo
****************************************



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch