Quoting perldoc -f undef:

undef EXPR undef Undefines the value of EXPR, which must be an lvalue. +Use only on a scalar value, an array (using "@"), a hash (using +"%"), a subroutine (using "&"), or a typeglob (using "*"). (Sa +ying "undef $hash{$key}" will probably not do what you expec +t on most predefined variables or DBM list values, so don't +do that; see delete.) Always returns the undefined value.

So, your if, while undef'ing $nomSQL, returns undef. And you can't perform a s/// substitution on an undefined variable.

Are you sure you don't want:

...

You know, I was going to post some code, but I really can't tell what you want to do. Obviously you want to 'escape' single quotes in an SQL statement, but it looks like you're trying your darndest to make sure the string is blank before you do it.

What do you want to do?



--chargrill
$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}

In reply to Re: Why undefined? by chargrill
in thread Why undefined? by pcouderc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.