<?xml version="1.0" encoding="windows-1252"?>
<node id="992096" title="Re^2: How check whether csv file with header is empty file or not in perl" created="2012-09-06 10:03:12" updated="2012-09-06 10:03:12">
<type id="11">
note</type>
<author id="200365">
Tux</author>
<data>
<field name="doctext">
&lt;p&gt;Let me edit your code, which is very unsafe once the CSV gets a little bit more complicated ...&lt;/p&gt;
&lt;code&gt;
use Text::CSV_XS;

my $csv = Text::CSV_XS-&gt;new ({ binary =&gt; 1, auto_diag =&gt; 1 });
open my $data, "&lt;", $file_c or die "$file_c: $!\n";
my $rows = 0;
while (my $row = $csv-&gt;getline ($data)) {
    $rows++;
    }
print "Total $rows rows (including header line)\n";
&lt;/code&gt;
&lt;p&gt;Though I'd probably go to an even simpler solution using [mod://DBD::CSV]:&lt;/p&gt;
&lt;code&gt;
$ ll xx.csv
12862169 -rw-rw-rw- 1 merijn users 415423 Sep  6 16:00 xx.csv
$ perl -MDBI -wE'say DBI-&gt;connect("dbi:CSV:f_ext=.csv")-&gt;selectrow_arrayref("select count(*) from xx")-&gt;[0]," rows in fs"'
8739 rows in fs
&lt;/code&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-200365"&gt;
&lt;br /&gt;
Enjoy, Have FUN! H.Merijn
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
992048</field>
<field name="parent_node">
992057</field>
</data>
</node>
