c:\@Work\Perl\monks>perl -wMstrict -le "my $inputtext = qq{a multi line\nstring and\nanother line\nthing here\n}; print qq{<<$inputtext>> \n}; ;; my $newText = replaceText($inputtext, qr{ lin .*? ing }xms, 'xx-xx'); print qq{<<$newText>>}; ;; sub replaceText { my ($inputText, $regex, $replacement) = @_; $inputText =~ s/$regex/$replacement/g; return $inputText; } " <> <>