My approach has been to do some quick post-processing. For example, this chunk from a processor that uses Text::CSV_XS for reading and splitting each line: null values are usually undef, and I change them to the string '<NULL>' that an up-stream processor requires.
$line = $csv->getline($io); # .. some error-handling stuff. for (@$line) { $_ = '<NULL>' unless defined } #~ @$line = map { defined $_ ? $_ : '<NULL>' } @$line
Note that commented-out line: that works just as well. I haven't benchmarked it, so I don't know which is faster, but other maintainers were griping about the map{}, so I replaced it.

The basic logic (in both cases) is that I look for undefined values (you could also look for the empty string by substituting $_ eq '' for defined $_) and replace them with something.

This is, in general, better than prefilling: you need not alter this code if the length of your lines change.

Anima Legato
.oO all things connect through the motion of the mind


In reply to Re: Auto-filling an array by legato
in thread Auto-filling an array by nimdokk

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.