in reply to Loop Through Files and Update Headers

I would not use Tie::File unless there is some user requirement of which I am not aware.
I would read the input file into memory, save input file as a backup, modify input file as in memory, write modified contents to the output file.
Untested, but hopefully gets you on the right track...
use strict; use warnings; my $inDir ="."; my @inFiles = glob ("$inDir/*.txt"}; foreach my $infile (@inFiles) { # read infile into memory.. open IN, '<', "$inDir/$infile" or die "$!"; my @lines = <$infile>; close IN; # save the original infile rename ("$inDir/$infile", "$inDir/$infile-backup") or die "$!"; # modify the data that's in memory unshift @lines, "whatever_you_want\n"; #save the new data into the original file name open (OUT, '>', "$inDir/$infile") or die "$!"; print OUT @lines; close OUT; }
There are issues when "something goes wrong" and Tie::File. The above saves a "backup" in the case of problems.