Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Undef values from file open

by Mr. Muskrat (Canon)
on Mar 22, 2016 at 21:07 UTC ( [id://1158549]=note: print w/replies, xml ) Need Help??


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

It works for me.

1/1/16, Mon, foo ("1/1/16", "Mon", "foo") 1/2/16, Tue, bar ("1/2/16", "Tue", "bar")

What does your data look like?

Replies are listed 'Best First'.
Re^4: Undef values from file open
by Anonymous Monk on Mar 22, 2016 at 21:12 UTC
    It still prints undefs:
    Test Data:
    01/04/2014,Friday,Joe 02/11/2011,Monday,Mary 05/09/2016,Monday,Ann 07/02/2013,MOnday,Marc

      Maybe you have trailing blank lines .

      while (my $line = <$lines>) { next unless $line =~ /\S/; # <- add chomp $line; . .

      What does your program look like?


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

        Here, and I can not get it to work:
        #!/usr/bin/perl 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/; # <- add chomp $line; my $data; ( $data->{ date }, $data->{ day }, $data->{ name } ) = split(/,/, $ +line); pp @{ $data }{ (@parms) }; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1158549]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found