I have a script where I am looping through all files in the folder and I am wanting to update the headers. The issue I am having is, it is looping through all the files and appending the new header but it is not copying down the remaining data in each file, it is only pasting the header. Can someone take a look at my code and tell me what is missing to append the remaining data in my files and not just the header.
use strict;
use warnings;
use Tie::File;
opendir IN, 'Output'; # name of folder where files are
my @in = grep { /\.txt$/ } readdir IN; # read all files in dir
closedir IN;
for my $in (@in) {
open IN, '<', "Output/$in" || next;
tie my @array, 'Tie::File', $in or die "Could not open file '$in' $!";
$array[0] = 'Header1, Header2, Header3, etc etc.';
untie @array;
}