in reply to Variable blasphemy

This: @tmpConv[0] should be this: $tmpConv[0]. (If you had use warnings, it would have told you that.)

You use @array to refer to the whole array, and $array[i] to refer to the individual scalars it contains.

Whether that will fix your problem I haven't checked, but its a good start.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Replies are listed 'Best First'.
Re^2: Variable blasphemy
by SixTheCat (Novice) on Jul 24, 2015 at 15:08 UTC
    I'll give it a try. Thanks!
Re^2: Variable blasphemy
by SixTheCat (Novice) on Jul 24, 2015 at 15:12 UTC
    Updated the code in the original post and added the "use warnings". Same output problems though. No warnings given. Sigh.
      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
        That worked! Thanks! Can you explain what the difference was (and what the above code means?) =P Thank you so much!
        The csv file was saved under windows, yes. Do I need to open it a different way?