in reply to Why undefined?

$nomSQL =~ s/'/''/;

NO NO NO NO NO

Investigate the use of placeholders in SQL, or use an available 'quoting' method.