Here's another step along the debugging path poj began here. We know that each line of the file is being read correctly; now, what happens when we process a line and assign its sub-strings to the  $data hashref?

c:\@Work\Perl\monks\Anonymous Monk\1158543>perl -e "use strict; use warnings; use Data::Dump 'pp'; ;; my $file_name = 'file.csv'; open my $lines, '<', $file_name or die qq{opening file '$file_name': $!}; ;; while (my $line = <$lines>) { pp $line; next unless $line =~ /\S/; chomp $line; my $data; ($data->{date}, $data->{day}, $data->{name}) = split(/,/, $line); pp $data; print qq{------- \n} } " "01/04/2014,Friday,Joe\n" { date => "01/04/2014", day => "Friday", name => "Joe" } ------- "02/11/2011,Monday,Mary\n" { date => "02/11/2011", day => "Monday", name => "Mary" } ------- "05/09/2016,Monday,Ann\n" { date => "05/09/2016", day => "Monday", name => "Ann" } ------- "07/02/2013,MOnday,Marc\n" { date => "07/02/2013", day => "MOnday", name => "Marc" } ------- "\n"
What do you get when you run this code? Note that my data file contains a blank line at the end for which no further processing is done, as expected, so this aspect of the program works.

BTW: I'd still be curious to know the exact version of Perl you're using. I don't really know what being "current" means.


Give a man a fish:  <%-{-{-{-<


In reply to Re^9: Undef values from file open by AnomalousMonk
in thread Undef values from file open by Anonymous Monk

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.