my $output_file = 'output_0000';
my $file_size = 0;
open(STDOUT,>,$output_file)
or die "Error opening $output_file for writing, ";
while (my $line = <>)
{
do_something($line);
if ($file_size > 50000)
{
close STDOUT
or die "Error closing $output_file, ";
$output_file++; # magic increment
open(STDOUT,>,$output_file)
or die "Error opening $output_file for writing, ";
$file_size = 0;
}
print $line;
}
Snippets of code should be wrapped in
<code> tags not<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).