use strict;
my $str = '{{mul|ab|ab|ab|ab|ab|ab}}
{{mul|aa|ab }}machintruc
brun}}{{mul|aa|ab}}
{{mul|fr|en|de}}[http//truc]
{{mul|fi|luo|en-gb|zh-hant }}{{chapitre|
{{mul|de|nl|fi|luo|en-gb|zh-hant }} {{lien web|
{{mr}} Trucmuche';
my $regex = qr/\{\{mul([^\} ]*) *\}\}([^\s])/mp;
my $subst = '{{mul$1}} $2';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html