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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.