Hi edrew04, here is a working version. The newly added lines are marked with '###'.
use strict;
use warnings;
use Text::CSV;
my @data; # 2D array for CSV data
my $file = 'AMS.csv';
my %dept_code = ( ###
1001 => 'IT', ###
1002 => 'HR', ###
1003 => 'PURCHASING', ###
);
my $csv = Text::CSV->new({ binary => 1, quote_null => 0 });
open my $fh, '<', $file or die "Could not open $file: $!";
while( my $column = $csv->getline( $fh ) ) {
push @data, $column;
}
open $fh, ">:encoding(utf8)", "PPS.csv" or die "PPS.csv: $!";
for (@data) {
$_->[0] += 2000; ###
$_->[7] = $dept_code{$_->[7]}; ###
$csv->print($fh, $_);
print $fh "\n";
}
close $fh or die "PPS.csv: $!";