use strict; use warnings; open(FH, ">tmp.txt") or die "OH NOOO!: $!"; print FH "x"; close FH; my (@done, @array) = qw(Why the heck am I even writing this stupid program?); { open(FH, ">>tmp.txt") or die "OH NOOO!: $!"; push @array, -s FH; print FH "x"; close FH; last if @array eq @done; redo; } print "@array\n";