Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
laziness, impatience, and hubris
 
PerlMonks  

Re: uninitialized value in join or string

by EvanCarroll (Chaplain)
on Oct 31, 2005 at 04:46 UTC ( [id://504204]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to uninitialized value in join or string

Observe:
perl -we'print join ",", @{[undef]}' Use of uninitialized value in join or string at -e line 1.
One of the values in your row, (columns returned from sql row) is NULL in sql, meaning undef in perl. Add to your sql statement, where not null or if your using Oracle employ nvl(), if postgres see coalesce().


Evan Carroll
www.EvanCarroll.com

Replies are listed 'Best First'.
Re^2: uninitialized value in join or string
by Win (Novice) on Oct 31, 2005 at 04:59 UTC
    Nice one-liner there. It may just be better if I replaced NULLs with ' 's (ie. spaces). Actually I don't know whether these NULL values are slowing my program down or not. I may just ignore the error message and not do anything about it. However, I am willing to take advice on that. There are problems with using WHERE NOT NULL as some of the values in the array are not NULL and these are required.
      You could always map over the array and set the undef values to '', I would personally suggest keeping the database pristine. I would use nulls if it increases data clarity for a more ugly solution in the perl base. '' would violate a unique constraint where as multiple nulls woulden't for instance. Nulls are also open to the database implimentation, and can be optimized away very easily, an empty string however is kept as just as that, rather than a small pointer to null.

      Update:
      or a simple join ",", grep defined, @row;


      Evan Carroll
      www.EvanCarroll.com
        How could I substitute all the NULL values in an array and replace them with ' ' characters?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://504204]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.