#!/usr/bin/perl use strict; use warnings; my $file = 'test.txt'; my $content = do{ local (@ARGV,$/) = $file; <> }; my $orig = "## ---------------------- ## muu ## ----------------------"; my $replace = "## Fisch ## Fleisch"; $content =~ s/\Q$orig/$replace/g; print $content;