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
In Section
Seekers of Perl Wisdom