The environment is the shell in which your program runs. That's an OS-dependent question. I didn't mean to force you to learn how to use your operating system too. Just remove the "if $ENV{....}" stuff.

Here's the point. There is nothing wrong with the code in your subroutine. Add to that the fact that your subroutine is very much a self-contained black box. There are no parameters being passed in, and no global values being absorbed into it. You are testing your "open" correctly, so we know the CSV file opened. You have "auto_diag" set, so we know your CSV object instantiated correctly, and that calls to $csv->getline($fh) aren't throwing errors. There are no points of possible failure except that you haven't proven that your CSV file contains any lines of CSV. You also haven't proven that after stripping away the first line, there are still more CSV lines to follow.

You have told us that your while() loop is never being entered. That can only happen if your CSV file has no lines of CSV after you strip the header.

Come to think of it, you're also not telling us how you know that your while() loop is never being entered. Put a "warn "I'm in the while loop!\n"; statement inside of your while loop, and prove to yourself that you're not entering it, as you've told us. If it turns out that you are entering it, then the problem exists within code that you haven't shown us, which means this has been a waste of an hour or so of time.


Dave


In reply to Re^5: Cannot work on second file after reading first file. by davido
in thread Cannot work on second file after reading first file. by 1straw

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.