title: How to escape comma in csv perl
body: <p>In my csv file there are thousands of records.And those records contain data with comma.How i should escape .I seen few links which mentioned about using module
  TEXT::CSV.But still issue persist ie recofds gets break where ever comma comes.
  Here is sample code i have been working:</p>
  
  <pre><code> use Data::Dumper qw(Dumper);
   my $file = $ARGV[0] or die "Need to get CSV file on the command line\n";
   use Text::CSV;
   my $csv = Text::CSV-&gt;new({ sep_char =&gt; ',' });
   my $file = 'Pkg_Notes_small.csv';
   my %data;
    my %dupes;
    open(my $data, '&lt;', $file) or die "Could not open '$file' $!\n";
  
   while (my $line = &lt;$data&gt;) 
   {
  
    my $catalog_num ='';
    my $catalog_sid ='';
    my $note_text ='';
    my $packing_notes_id ='';
    #($catalog_num,$catalog_sid,$packing_notes_id,$note_text) = split ',', $line;
    if ($csv-&gt;parse($line)) 
    {
        my @fields = $csv-&gt;fields();
        $catalog_num = $fields[0];
        $catalog_sid = $fields[1];
        $packing_notes_id = $fields[2];
        $note_text = $fields[3];
       }
     }
  </code></pre>
  
  <p>i will add sample data from csv file : </p>
  
  <pre><code>CATALOG_NUM  CATALOG_SID    PACKAGING_NOTES_SID    PACKAGING_NOTES_DESC
  
  
  112194  ,     521     ,        77      ,        For WI Packaging Operations: For 
                                 finishing  operations, the  use of a protective 
  </code></pre>
  
  <p>comma used above for clarity. Now converting this data to query based on my requirement for which i am getting:</p>
  
  <p>for which <strong>Notetext</strong> field i am getting is :</p>
  
  <pre><code>    For WI Packaging Operations: For finishing operations  
  </code></pre>
  
  <p>remaining part for this line after processing is missed out.the data iam expecting  is :</p>
  
  <pre><code>  For WI Packaging Operations: For 
    finishing  operations, the  use of a protective
  </code></pre>