I apologize for the poorly constructed explanation and I do appreciate your help very much. A text file with a single line consisting of ~155e6 characters, all 0's and N's, is read in as a scalar variable. Each character is assigned to a single element of an array:

open(INPUT, "/Users/logancurtis-whitchurch/Dropbox/thesis_folder/conse +nsus_files/mask_files/mask."."$population".".chr.23.txt") or die "can +'t open masked file\n"; ;; my $input = <INPUT>; ;; chomp($input); ;; my @info = split( //, $input );

I'd like to read each element of @info sequentially, at the same time have a scalar $length that corresponds to the length from the beginning of @info, $info[0], to the current, farthest position being read, say $info[3000] where $length would equal 3001. With this information I can tell the program, if $length is within the bounds of my current interval values ( $start and $end) go on to the next element of @info and increment $length and so on until $length is greater than $end, in which case I increment my interval values which have been similarly assigned to an array from an input text file. Then I would like to tell the program if $length is less than $start change the current element of @info to an 'N' , move to the next element of @info and increment $length. The goal: change all elements of the @info array that lie outside of my intervals to N's.

this shows the format of my interval input file and how I assign $start and $end values:

input format for intervals: chrX 1 6000 chrX 6045 6302 chrX 7204 8239 ...etc until all 155e6 positions have been covered. my $filtered_sites = "/Users/logancurtis-whitchurch/Dropbox/thesis_fol +der/galaxy_chrX_data/filtered_chrX_rawdata.interval"; ;; open (INTERVAL, "<$filtered_sites") or die "can't open $filtered_sites +"; ;; my @interval = <INTERVAL>; ;; close (INTERVAL); ;; chomp (@interval); ;; my @site_info= split(/\t/, $interval[$count]); ;; my $start = $site_info[1]; ;; my $end = $site_info[2]; ;;

so every time $length is greater than $end I increment $count to assign new $start and $end values.


In reply to Re^2: A question About Array Indexing by ccelt09
in thread A question About Array Indexing 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.