#!/usr/bin/perl use constant DAILY_RUN => 1024 * 1024 * 1000; use strict; use warnings; my $file = $ARGV[0] or die "Usage: $0 "; open(my $fh, '<', $file) or die "Unable to open '$file' for reading: $!"; my $cnt = 1; my $out_file = "$file.$cnt"; # Will clobber an existing file by this name (fix if important) open(my $out_fh, '>', $out_file) or die "Unable to open '$out_file' for writing: $!"; while (<$fh>) { if (-s $out_file > DAILY_RUN && /^100/) { ++$cnt; $out_file = "$file.$cnt"; open($out_fh, '>', $out_file) or die "Unable to open '$out_file' for writing: $!"; } print $out_fh $_; }