in reply to hash help

Another possible solution?
#!/usr/bin/perl use strict; my $file_1 = <<EOF; Bbbb,3333,4444 Cdd,3444,3444 Zddd,345,456 EOF my %records; open( my $fh, "<", \$file_1 ) or die "error opening file."; while( <$fh> ) { chomp; my @cols = split( "," ); $records{$cols[0]} = "$cols[1],$cols[2]"; } close( $fh ); while (<DATA>) { my @cols = split( "," ); $cols[0] =~ s/_\w+//; print "$cols[0],$records{$cols[0]},$cols[1],$cols[2]"; } __DATA__ Bbbb_rf1,23,45 Cdd_rf2,24,45 Zddd,34,456.4