title: Perl read CSV and manipulate dates and numbers
body: <p>I have run up to a problem and invested quite a few hours into understanding it...</p>
  
  <p>I want to read a .csv file using perl, look for a date (and numbers), arrange the date to another format and add the numbers to an existing number.</p>
  
  <p>The data in the .csv are simple fields with the ";" delimeter.</p>
  
  <p>The date exists in the format 01.01.2000 in the .csv file and I would like to format ist to 2000-01-01. The amount exists in the form "-200".</p>
  
  <p>Now the reading and putting it into variables works fine. 
  However the variables dont behave like the others, I cannot properly use regex on them and if I try to add the amount to another vaiable I get the following error:
     Argument "\x{0}-\x{0}5\x{0},\x{0}6\x{0}6\x{0}" isn't numeric in addition (+)</p>
  
  <p>Now it looks to me like there is an issue with the encoding of the data, that I did not handle correctly, but after several tries of "endode, decode, upgrade downgrade etc" I just can't get it to work.
  And if I save these variables to a text file and open that manually, it tells me that the file is encoded in utf8 and for read-only.</p>
  
  <p>What am I missing here and what do I need to understand concerning the encoding, I read a lot about it but I still don't really get it in my case.</p>
  
  <p>Edit:
  Sorry for my previous insufficient code. The following code should work on its own:</p>
  
  <pre><code>#!/usr/bin/perl -w
  use strict;
  use warnings;
  use utf8;
  use Text::CSV;
  use Data::Dumper qw(Dumper);
  
  my $file = "test.csv";
  my $s_delimiter = ";";
  
  open(my $fh, '&lt;', $file) or die("ERROR open $file ($!)\n");
  
  my $csv = Text::CSV-&gt;new({binary =&gt; 1, sep_char =&gt; $s_delimiter});
  
  # read File
  while( my $row = $csv-&gt;getline( $fh ) )
  {
      my @array = @{$row};
      my $arraylength = @array;
  
      my $date = $array[2];
      my $amount = $array[6];
  
      $amount += 200;
  
      print "$amount\n";
      $date =~ /(\d\d).(\d\d).(\d\d\d\d)/;
  
      print "$date\n";
      print "$3 $2 $1\n";
  }
  
  close $fh;
  </code></pre>
  
  <p>Thanks for your help in advance! </p>