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. And what's the '+' after 'size2' in the declaration line? That was caused by PerlMonks line-wrapping.
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.
while ( my $line = <FH> ) { chomp $line; next unless length $line; my ( $file, $patientName, $panel, $snp, $allele1, $allele2, $size1 +, $size2 ) = split "\t", $line; $snp ||= 'missed'; if ( $allele1 && $allele2 ) { constructHetero( $snp, $patientName, $allele1, $allele2 ) } elsif ( $allele1 && not $allele2 ) { constructHomo( 'type1', $snp, $patientName, 'allele1', $allele +1 ) } elsif ( not $allele1 && $allele2 ) { constructHomo( 'type2', $snp, $patientName, 'allele2', $allele +2 ) } elsif ( not $allele1 && not $allele2) { constructUnclassified( $snp, $patientName ) } }
update 3 : Changed from '!' to 'not' for negation, better visibility.
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
In reply to Re: Text Analysis: given(){when(){}} block throws a 'useless use of private variable...etc' error
by TomDLux
in thread Text Analysis: given(){when(){}} block throws a 'useless use of private variable...etc' error
by biohisham
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |