![]() |
|
No such thing as a small change | |
PerlMonks |
Re: Text Analysis: given(){when(){}} block throws a 'useless use of private variable...etc' errorby TomDLux (Vicar) |
on Oct 18, 2010 at 13:56 UTC ( [id://865938]=note: print w/replies, xml ) | Need Help?? |
Do you suppose the backslash at the end of line 1 has anything to do with it? Update: There's a closing curly missing at the end of the main line, before the first subroutine. update 2: SOLVED! given() takes a single variable or value, and assigns it to $_, so that in the various when() clauses, you can test $_ with various values / regex / routines. I'm quessing $_ is the private variable which is not used. You don't need to assign empty strings to the variables, nor do you need to compare against an empty string, undef or empty string are both 'false' in a boolean concept, that's a design feature, not an accident. Also, When reading a file, just read into a buffer variable, the read operation assigns undef to the buffer, ending the loop. I chomp the line when read, and skip empty lines, because I was getting an empty line at the end of the data file. Also, I use ||= to assign 'missed' to $snp if it doesn't have a string value. I'm not a biologist, but 'homo' means 'the same', 'hetero' means 'different'. So I'm thinking when allele1 and allele2 are both set, it should be 'homo', and 'hetero' should apply when only one is set.
update 3 : Changed from '!' to 'not' for negation, better visibility. As Occam said: Entia non sunt multiplicanda praeter necessitatem.
In Section
Seekers of Perl Wisdom
|
|