in reply to Re^4: Read CSV with column mapping
in thread Read CSV with column mapping
scalar(@$colref) is the number of items found in the column, it would never contain a '#' symbol.
$colref->[0] is the first item on the line read in, it could contain a # symbol.
if ($colref->[0] =~ /^#/) { next; }
Notice i said next rather than last. next will go on to the next row, last will end the do loop and stop reading any more lines.
the next condition is a touch more tricky.
See we have to test all of the items in this case. Note th use of last here, as soon as we have found any nonblank we dont have to check anymore.my $anynonblank=0; for my $item (@$colref){ unless ($item =~ /^\s+$/) { $anynonblank=1; last; } } unless ($anynonblank) { next; }
edit: opps , fixed as per Re^6: Read CSV with column mapping below
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Read CSV with column mapping
by AnomalousMonk (Archbishop) on Dec 16, 2018 at 06:31 UTC | |
Re^6: Read CSV with column mapping
by coretele (Novice) on Dec 16, 2018 at 17:59 UTC | |
by Tux (Canon) on Dec 17, 2018 at 07:59 UTC | |
by BillKSmith (Monsignor) on Jun 21, 2019 at 12:36 UTC | |
by poj (Abbot) on Dec 16, 2018 at 18:17 UTC | |
by coretele (Novice) on Dec 17, 2018 at 21:43 UTC | |
by poj (Abbot) on Dec 18, 2018 at 19:45 UTC | |
by coretele (Novice) on Dec 25, 2018 at 04:47 UTC | |
by huck (Prior) on Dec 16, 2018 at 18:22 UTC |
In Section
Seekers of Perl Wisdom