I don't know if anyone is still reading this thread, but I think that the problem that's making the program crash is the undef values in the data structure

I've written some code to attempt to replace each undef with some fake data that flags a window as undef, but what I've written doesn't seem to be modifying the output. Perhaps someone can tell me how to fix this:

while (<$in_file>) { chomp; if (/^SAMPLE/) { my ( $placeholder, @coords ) = split /,/; foreach my $coord (@coords) { push @snp_bins, int( $coord / 100_000 ); } } else { my ( $id, @snps ) = split /,/; foreach my $snp (@snps) { # (@snps[0..$#snps-1] $snp =~ s/$snp/$snp,/ # put commas back in (preserve cs +v format) } foreach my $index ( 0 .. $#snp_bins ) { if ( $snps[$index] ) { push( @{ $data{$id}[ $snp_bins[$index] ] }, $snps[$index] +); # see note [1] } else { # replace 'undef' elements with f +lag data my @ones_array; foreach ( 1 .. 100) { push @ones_array, "1 1,"; } push( @{ $data{$id}[ $snp_bins[$index] ] }, @ones_arra +y ) } } } }

I am assuming that the problem lies with the line

if ( $snps[$index] )

Is this the case, and if so how can I fix it? Help appreciated.


In reply to Re^7: Population of HoAoA based on file contents by iangibson
in thread Population of HoAoA based on file contents by iangibson

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.