in reply to convert string into a match pattern

Which characters would I have to escape from a string, that I do not miss any ?

Use the \Q and \E quoting expressions to retain all those parts you wish to use as literal strings:

use strict; use warnings; use Test::More; my @good = ( 'nnxx.yy2 = 333 abc', 'nnxx.yy2 = 1 abc', 'nnxx.yy2 = 2345 abc', ); my @bad = ( 'foo', 'nnxxayy2 = 1 abc', 'nnxx.yy2 = 1a abc', ); my $re = qr/^\Qnnxx.yy2 = \E\d+\Q abc\E$/; plan tests => @good + @bad; for my $str (@good) { like ($str, $re, "$str matched"); } for my $str (@bad) { unlike ($str, $re, "$str not matched"); }