#!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path /; use Time::Piece qw/ localtime /; use Data::Dump qw/ dd /; my $date = localtime()->strftime("%m-%d-%Y"); my $logprefix = "7252_Widevine_OemCrypto_Consolelog_User1"; my $logfile = $logprefix.'_'.$date.'.txt'; for my $ix ( 0 .. 3 ){ my $fh = path( $logfile )->opena_raw; print $fh "$ix\n"; close $fh; dd( path( $logfile )->slurp_raw ); } __END__ "0\n" "0\n1\n" "0\n1\n2\n" "0\n1\n2\n3\n"