Last active
November 9, 2017 13:12
-
-
Save Code-Hex/bc2dba508ffd6aa9e3945c4876960def to your computer and use it in GitHub Desktop.
Maybe easy to get csv data??
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use feature qw/say/; | |
use Text::CSV; | |
my $csvfile = 'hello.csv'; | |
my $csv = Text::CSV->new({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag(); | |
open my $fh, '<', $csvfile or die "Could not open $csvfile: $!"; | |
my $i = 0; | |
$csv->column_names ($csv->getline($fh)); | |
while (my $row = $csv->getline_hr($fh)) { | |
say join ', ', ($row->{name}, $row->{age}, $row->{hobby}); | |
} | |
$csv->eof; | |
close $fh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name | age | hobby | |
---|---|---|---|
kei | 22 | perl | |
taro | 20 | soccer | |
hanako | 20 | eating | |
foo | 38 | bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment