use strict; use warnings; my $out = "Rows_of_interest.txt"; open (OUT, "+>$out"); open my $fh, "<", "gridall.csv" or die "gridall.csv: $!\n"; my $all_lines; my $matched_line_count; #my $csv; while (my $row = my $csv->getline($fh)) { $all_lines++; $row->[8] =~ m/^CE$/ or next; print OUT $row; $matched_line_count++; } $csv->eof or $csv->error_diag (); print "\n\nNumber of lines detected:\t$all_lines\n\n"; print "\n\nNumber of matched lines detected:\t$matched_line_content\n\n";