in reply to Re^2: Variable blasphemy
in thread Variable blasphemy
Assuming each RSno has only one StarName and vice versa, it would be simpler to use a hash for the conversion
poj#!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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Variable blasphemy
by SixTheCat (Novice) on Jul 24, 2015 at 15:51 UTC | |
by GotToBTru (Prior) on Jul 24, 2015 at 16:36 UTC | |
|
Re^4: Variable blasphemy
by SixTheCat (Novice) on Jul 24, 2015 at 15:49 UTC | |
by Monk::Thomas (Friar) on Jul 24, 2015 at 15:55 UTC |