Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: uninitialized value in join or string

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


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

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

Replies are listed 'Best First'.
Re^4: uninitialized value in join or string
by Win (Novice) on Oct 31, 2005 at 14:40 UTC
    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.
        This looks great. However, I would be very pleased if somebody could describe it in English. ;>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://504213]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-10-07 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (44 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.