Dear All, The below is my input data:
$ cat demo.txt 159350,PP02,Backup,0,Done 159349,B02_bkp,Backup,0,Done 159347,B02_bkp,Backup,0,Done 159346,B02_bkp,Backup,0,Done 159345,B02_bkp,Backup,0,Not 159344,02_bkp,Backup,0,Done I am using Text::CSV_XS to read the above comma separated file. Here is the code I am using the above file line by line. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Text::CSV_XS; my $file="/data/demo.txt"; if(defined $ARGV[0]) { $file=$ARGV[0]; } my $csv = Text::CSV_XS->new({binary => 1,sep_char => ','}) or die "Cannot use CSV: ".Text::CSV->error_diag (); open(my $data, '<', $file) or die "Could not open '$file'\n"; while (my $line = <$data>) { if ($csv->parse($line)) { my @row = $csv->fields(); print "$row\n"; // compare and replace string name to id. } else { warn "Line could not be parsed: $line\n"; } } I have two hash reference like : $VAR1 = \{ '1' => { 'name' => 'Backup', 'id' => '1' }, '2' => { 'name' => 'Catalog', 'id' => '2' } }; $VAR2 = \{ '1' => { 'name' => 'Done', 'id' => '1' }, '2' => { 'name' => 'Not', 'id' => '2' } }; I want to compare $row[2] and $row[4] with the above hash and want to replace string name to respective id. for example: 159350,PP02,1,0,1 159349,B02_bkp,1,0,1 159347,B02_bkp,1,0,1 159346,B02_bkp,1,0,1 159345,B02_bkp,1,0,2 159344,02_bkp,1,0,1 Any pointer would be greatly *appreciated. Thanks for your time. Thanks Mohan L *