Created
October 20, 2011 03:09
-
-
Save hayajo/1300322 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 5.008_001; | |
use Text::CSV; | |
use Data::Dumper; | |
use constant COLUMNS => [ qw/NAME EMAIL MEMO/ ]; | |
my $csv = Text::CSV->new({ auto_diag => 1 }); | |
$csv->column_names(@{ &COLUMNS }); | |
my $fcol = [ $csv->column_names ]->[0]; | |
while (my $row = $csv->getline_hr(*{DATA})) { | |
if ($row->{$fcol} =~ /^\s*#/) { | |
warn "comment line: $row->{$fcol}"; | |
next; | |
} | |
warn Dumper $row; | |
} | |
__DATA__ | |
#1 comment line 1 | |
#2 comment line 2 (spaces head) | |
#3 comment line 3 (tab head) | |
hoge,[email protected],hogehogehoge | |
fuga,[email protected],fugafugafuga | |
piyo,[email protected],piyopiyopiyo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment