Are you reading a windows file on a unix machine ?
Try changing chomp to s/\s+$//g;
Update:
Assuming each RSno has only one StarName and vice versa, it would be simpler to use a hash for the conversion
#!perl
use strict;
my @Stars = qw(CYP2C19_10 CYP2C19_12);
return if (@Stars == 0);
# name,no
my $ref_file = "test.csv";
open my $star_FH,'<',$ref_file
or die "Could not find reference file $ref_file : $!";
my %RSno=();
my $count=0;
print "Reading from ref_file $ref_file .. ";
while (<$star_FH>){
s/\s+$//;
my ($no,$name) = split ",",$_;
$RSno{$name} = $no;
++$count;
}
close $star_FH;
print "$count records read\n";
for my $StarIndex (@Stars){
if (exists $RSno{$StarIndex}){
print "$StarIndex is $RSno{$StarIndex}\n";
} else {
print "$StarIndex NO CONVERSION\n";
}
}
poj
|