jalopez453 has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loop Through Files and Update Headers
by choroba (Cardinal) on Mar 05, 2020 at 22:54 UTC | |
|
Re: Loop Through Files and Update Headers
by kcott (Archbishop) on Mar 06, 2020 at 06:58 UTC | |
|
Re: Loop Through Files and Update Headers
by choroba (Cardinal) on Mar 05, 2020 at 23:24 UTC | |
|
Re: Loop Through Files and Update Headers
by Marshall (Canon) on Mar 07, 2020 at 03:32 UTC |