# make sure $fh is the file-handle to the CSV stream # with the CSV data in memory (say it is in $data), you can # use perlio: # open my $fh, "<", \$data; my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); while (my $row = $csv->getline ($fh) { @$row or next; # skip empty lines if ($indata == 0) { @data = @$row; if ($row->[0] eq "Subject:") {