#!/usr/bin/env perl use 5.010; use strict; use warnings; use Text::CSV; my $ic = Text::CSV->new({sep_char => ','}) or die Text::CSV->error_diag(); my $oc = Text::CSV->new({sep_char => ',', eol => $/ }) or die Text::CSV->error_diag(); open my $if, '<', 'infile' or die $!; open my $of, '>', 'outfile' or die $!; my %states = ( '0H' => 'OHIO', '0R' => 'OREGON', ); while( my $r = $ic->getline($if)){ $r->[0] = 'CONDENSED' if $r->[0] eq 'C'; $r->[0] = 'FINAL' if $r->[0] eq 'F'; $r->[4] = $states{$r->[4]} if $states{$r->[4]}; $oc->print($of, $r); } close $if; close $of;