in reply to limit output filesize
the output was as follows (abridged):#!/usr/bin/perl use warnings; use strict; my $file_base = "output"; open( FILE, ">$file_base" ) or die "Unable to open $file_base for writ +ing!\n$!\n"; for (1..100) { print FILE "0" x 1024; print "File Size: ".(stat($file_base))[7]."\n"; last if (stat($file_base))[7] > 50000; } close FILE or die "Error closing $file_base\n$!\n";
So it stopped close to, but not at, 50k because while the file is open, only full blocks are written. You may want to keep that in mind and make sure the cutoff is at the highest blocksize that is less than your threshold.File Size: 0 File Size: 0 File Size: 0 File Size: 0 File Size: 4096 File Size: 4096 File Size: 4096 File Size: 4096 ... File Size: 49152 File Size: 49152 File Size: 49152 File Size: 53248
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: limit output filesize
by rogue90 (Novice) on Jul 08, 2005 at 19:12 UTC | |
by bart (Canon) on Jul 08, 2005 at 19:28 UTC | |
by rogue90 (Novice) on Jul 08, 2005 at 19:45 UTC | |
by rogue90 (Novice) on Jul 08, 2005 at 19:37 UTC |