in reply to Re^2: truncating a text file
in thread truncating a text file

Oops,

# Keep the last 5. if (@sets > 5) { @sets = @sets[-5..-1]; }

should be

# Keep the first 5. if (@sets > 5) { @sets = @sets[0..4]; }

It's a remenant of an incorrect version I wrote before posting.

(I updated my earlier post to remove the error.)