#!/usr/bin/perl use warnings; use strict; my $file = 'datei'; my $tmpfile = "$file.tmp"; my %changes = ( 'eintrag1' => 'XXXX', 'eintrag2' => 'foo', # etc. ); open(my $fh, '<', $file) or die $!; open(my $th, '>', $tmpfile) or die $!; LINE: while (my $line = <$fh>) { KEY: for my $key (keys %changes) { if ($line =~ s/($key\s*=\s*)[^#\s]+/$1$changes{$key}/) { print $th $line; next LINE; } } print $th $line; # kein Match } close($fh) or die $!; close($th) or die $!; unlink $file; # oder als Backup speichern rename $tmpfile, $file;