The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IO::File::Cycle - Easily split output file while writing

VERSION

Version 0.03

SYNOPSIS

This module makes it easy to split a file while writing to it. This, for example, will create a number of files in /tmp called "foo.1.txt", "foo.2.txt", &c., all at most 10,000 bytes in size:

        use IO::File::Cycle;

        my $file = IO::File::Cycle->new('>/tmp/foo.txt');
        for ( 1..100_000 ) {
                $file->cycle if tell($file) + length($_) + 1 > 10_000;
                print $file $_, "\n";
        }
        $file->close;

SUBROUTINES/METHODS

start_at()

Defines the starting number, which can be easily overridden in a subclass.

open()

Sets up some internal variables, then calls IO::File::open().

format_filename()

Formats the filename.

cycle()

Closes the current file, then opens a new file with an incremented number in the filename (before the extension if there is one, and after a "."). After closing the initial file, it renames it to have the index "1" – for example, "filename.1.ext".

filename()

Returns the current file's name. This can be called from a close() method in a subclass to post-process each file.

close()

This is a sample close() method, which in a subclass could post-process each file.

sub close { my $io = shift; my $filename = $io->filename; $io->SUPER::close; system "gzip -f $filename"; }

AUTHOR

Nic Wolff, <nic at angel.net>

BUGS

Please report any bugs or feature requests to bug-io-file-cycle at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IO-File-Cycle. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

        perldoc IO::File::Cycle

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2012 Nic Wolff.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 80:

Non-ASCII character seen before =encoding in '– for'. Assuming UTF-8