Hello Perl Monks! I am having difficulty discerning the source of an error in my code and or/input data. I attempt to filter data from one file to another based on what I call start and end positions.
open (CG, "<$cg_input") or die "can't open $cg_input\n"; my @SNPs = <CG>; close(CG); my $interval = "/Users/logancurtis-whitchurch/Desktop/chrX_divisions/" +."$region"."_$filter".".txt"; #specifiecs intervals by region and fil +ter version open (INTERVAL, "<$interval") or die "can't open interval file\n"; foreach ( <INTERVAL> ) { my (undef, $start, $end) = split '\s+', $_; my $switch = 1; while ($switch == 1) { my @get_SNPs = split('\s+', $SNPs[$placeholder]); my $position = $get_SNPs[3]; if (($position < $start) && ($position < $end)) { $placeholder++; } if (($position >= $start) && ($position <= $end)) { print OUT "@get_SNPs\n"; $placeholder++; } if (($position > $start) && ($position > $end)) { $switch =! 1; } } } close(INTERVAL);
The error message returned to me is as follows on repeating loop, until I terminate the program. Line 246 of my interval input file corresponds to the last line of the file, which looks no different from any of the others. I am at a loss regarding the uninitialized value, especially when identically formatted files have worked with the same code.
Use of uninitialized value in split at filter.CGS.pl line 43, <INTERV +AL> line 264. Use of uninitialized value $position in numeric lt (<) at filter.CGS.p +l line 46, <INTERVAL> line 264. Use of uninitialized value $position in numeric lt (<) at filter.CGS.p +l line 46, <INTERVAL> line 264. Use of uninitialized value $position in numeric ge (>=) at filter.CGS. +pl line 50, <INTERVAL> line 264. Use of uninitialized value $position in numeric gt (>) at filter.CGS.p +l line 54, <INTERVAL> line 264. Use of uninitialized value in split at filter.CGS.pl line 43, <INTERVA +L> line 264.
In reply to Tracing an Uninitialized Error by ccelt09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |