Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl file size limit

I know how to read|write|open files in perl. What am trying to achieve is this; how do I create a new file when the existing file exceeds 'x' size. For instance, I have a 3MB file size, before writing to the same file, check the size, if size exceed 3MB, create a new one, chmod it if needed, then write.

I don't know if my question is clear -

like image 662
James lubor Avatar asked Feb 12 '26 06:02

James lubor


1 Answers

$size = -s '/path/to/file.txt';

if(($size / 1048576) > 3) { print "too big"; } else { do_something(); }

like image 51
Captain Hawaii Avatar answered Feb 15 '26 02:02

Captain Hawaii



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!