in reply to regular expression code not working

my @lines = split "\n", $schema; for (@lines) { ... s/\)\n/\);\n/; ... }

None of the substrings split from  $schema in the
    my @lines = split "\n", $schema;
statement will contain a newline because you're splitting on a newline, thus the match regex of  s/\)\n/\);\n/; will never match.

To add a ';' (semicolon) after a ')' (right-paren) that was at the end of a newline-terminated line, try
    s{ \) \z }{);}xms;
or maybe to be on the safe side
    s{ \) \s* \z }{);}xms;
(I assume you're stitching all the lines back together with something like a
    $schema2 = join "\n", @lines;
statement).