in reply to Re^6: Undef values from file open
in thread Undef values from file open

Here's what I get from the code you just posted and the data from above:

c:\@Work\Perl\monks\Anonymous Monk\1158543>perl -e "use strict; use warnings; ;; use Data::Dump 'pp'; use Data::Dumper; ;; my $file_name = \"file.csv\"; ;; open my $lines, '<', $file_name or die \"Can't open file $file_name, $!\"; ;; my @parms = qw( date day name ); ;; while (my $line = <$lines>) { next unless $line =~ /\S/; chomp $line; my $data; ( $data->{ date }, $data->{ day }, $data->{ name } ) = split(/,/, $ +line); pp @{ $data }{ (@parms) }; } " ("01/04/2014", "Friday", "Joe") ("02/11/2011", "Monday", "Mary") ("05/09/2016", "Monday", "Ann") ("07/02/2013", "MOnday", "Marc")


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

Replies are listed 'Best First'.
Re^8: Undef values from file open
by Anonymous Monk on Mar 22, 2016 at 23:19 UTC
    It's a mystery to me, why this line:
    print "$data->{ date }, $data->{ day }, $data->{ name }\n"
    prints all the values and this one gets me undefs:
    pp @{ $data }{ (@parms) };
    I'm stuck on this one!
Re^8: Undef values from file open
by Anonymous Monk on Mar 22, 2016 at 22:10 UTC
    And this line prints anything for you?
    pp @{ $data }{ (@parms) };

      It prints what I posted:

      ("01/04/2014", "Friday", "Joe") ... ("07/02/2013", "MOnday", "Marc")
      What I posted was a line-by-line screenshot (a lineshot?) (update: aka a cut-and-paste) of my Windows command line interpreter window for your program and its output.


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