This is slightly easier on (my) eyes...
my $text = <<END;
create table foo (
somevar1 sometype,
somevar2 sometype null,
somevar3 sometype not null,
somevar4 sometype(20),
somevar5 sometype(20) null,
somevar6 sometype(10))
END
my $header = qr/create\s+table\s+\w+\s*\(\s*/;
my $name = qr/\w+\s*/;
my $type = qr/\w+\s*/;
my $op_char = qr/(?:\(\d+\)\s*)?/;
my $words = qr/(?:\w+\s*)*/;
my $decl = qr/$name $type $op_char $words/x;
my $comma = qr/,\s*/;
my $rest = qr/\)\s*/;
$text =~ s{($header)
((?: $decl $comma)*
$decl)
($rest)}
{
$1 . (join ",",
map {$_ . (/null\s*$/ ? "" : " NOT NULL")}
split(/,/, $2)) . $3
}gex;
print $text;