in reply to Re: uninitialized value in join or string
in thread uninitialized value in join or string

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.
  • Comment on Re^2: uninitialized value in join or string

Replies are listed 'Best First'.
Re^3: uninitialized value in join or string
by EvanCarroll (Chaplain) on Oct 31, 2005 at 10:08 UTC
    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.

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

    Evan Carroll
      How could I substitute all the NULL values in an array and replace them with ' ' characters?
        @values = map { defined $_ ? $_ : '' } @values;
        Update: don't use map for transforming something into itself. If you're getting from a different source, though, this would be an appropriate technique.

        Caution: Contents may have been coded under pressure.