The first argument you're passing to writeCSVfile does not appear to be what you're expecting in that subroutine.

Or at least it looks like you're mixing up $flatfile, $filename and $linename in several places.

also a couple of useless things that are in your code:

@flatfields = ("$sys_time", "$consent", "$user_name", "$company", "$u +ser_email");
is the same as
@flatfields = ($sys_time, $consent, $user_name, $company, $user_email +);
since those values are already strings (and even if they weren't, perl will convert them for you when you treat them as strings anyway).

And map{} does a local $_ already, so there's no need to do an explicit local $_ in your code.

So taking all that in account, you may want

$linename = join(",", map { s/"/""/g; qq("$_") } $sys_time, $consent, +$user_name, $company, $user_email);
instead.

In reply to Re: a classic : 'Premature end of script headers' problem by Joost
in thread a classic : 'Premature end of script headers' problem by hmbscully

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.