El usuario raíz no necesita autenticarse para sudo y, como tal, no es necesario que ingrese una contraseña para ejecutar un comando como otro usuario.
De sudoers
página de manual:
User Authentication
The sudoers security policy requires that most users authenticate themselves
before they can use sudo. A password is not required if the invoking user is root,
if the target user is the same as the invoking user, or if the policy has disabled
authentication for the user or command. (...)
Это вы используете двойные кавычки. Вы не можете использовать двойные кавычки «внутри» двойных кавычек, если они не экранированы. Вместо этого вы можете либо избежать двойных кавычек, либо, что более предпочтительно, использовать альтернативные кавычки, используя одинарные кавычки:
#!/usr/bin/perl
use warnings;
use strict;
exec("sed -i -r '4{s/\{\+//; s/\+}//; s/\[-.*-]//g}' error.txt");