I have a file containing positions, length and text, in paragraph format. eg first filed is position, the number in the second field is the length of the text in the forth field, the third field is the name.
0 10 ab hellothere 4 5 ac notimportant 2 3 ad notimportant 10 23 ab hellloagainhellloagainnn 4 5 ac notimportantnotimportant 2 3 ad notimportantnotimportant
I have another file containing positions of paragraph text I need to retain, relative to the top line (ab) of the paragraph
0 20 40 60 100 120
so the first line says to keep the text up to position 20 (keeping paragraph structure)
hellothere notimportant notimportant hellloagainhellloagai notimportantnotimport notimportantnotimport
Then I would need to keep the text from position 40 to 60, and so on. So I need to filter the text based on the positions in the second file (which gives the co-ordinates of the filtered text relative to the first line in the paragraph). Hopefully this makes sense. I am already reading in the data 1 paragraph at a time and processing the resulting text. the paragraph text and names is read into an hash
my %seqs foreach my $sline (@slines){ my($start,$size,$name,$text) = split /\s+/, $sline; $seqs{$name} = $text; }
I was hoping somebody may have an idea for some kind of filter before it is put into the hash, the tricky bit for me is using the info in the second file. Many thanks!

In reply to filter one file based on another by coldy

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.