NAME

Labrador::Common::FileWriter

SYPNOPSIS

	use Labrador::Common::FileWriter;
	my $writer = new Labrador::Common::FileWriter('/tmp/testwrites%%.log', 5);
	for(my $i=0;$i<rand(10);$i++)
	{
    	for (my $j=0;$j<rand(10); $i++)
	    {
    	    my $fileh = $writer->write();
	        print $fileh "$i $j\n";
    	}
	}
	$writer->finish;

DESCRIPTION

Provides a filehandle that rolls over to the next file after a constant number of writes.

METHODS

new($filename, $maxwrites, [$compress])

Constructor. $maxwrites is the limit to the number of times write() can be called before a new filehandle will be opened. If $compress is set, then the file is compressed by calling gzip when each file is closed.

write()

Returns a filehandle of an open file, and incremenents writecounter. If writecounter's maximum is exceeded, then the current file is closed and a new file opened.

finish

Close the filehandle.

PRIVATE METHODS

As usual, these should be never manipulated by external objects directly. Documentation is provided for completeness only.

_filename

Returns the name of the file to be opened given the object's current state.

_open()

Opens a new file.

_close

Closes the currently open file.

DESTROY Destructor - calls _close if the file is open.

REVISION

	$Revision: 1.6 $