use Tie::File; use strict; use warnings; my $file = '/path/to/file.ini'; tie my @array,'Tie::File',$file or die $!; foreach my $line(@array){ if($line =~ /DEIN_MUSTER/){ chomp $line; $line .= "Anhang\n"; } } untie @array;