When initialising your @arr1 array you could save a yourself a heap of fiddly and error-prone typing by using a map with the qw{ ... } quote words operator. E.g.

johngg@shiraz ~ $ perl -Mstrict -Mwarnings -MData::Dumper -E ' my @arr1 = map qq{$_:}, qw{ 91 86 184 430 }; print Data::Dumper->Dumpxs( [ \ @arr1 ], [ qw{ *arr1 } ] );' @arr1 = ( '91:', '86:', '184:', '430:' );

You might also make things easier for yourself (and any others maintaining your code) by using meaningful variable names rather than $c, $i or $j.

It is not clear from your description and your code exactly what you are trying to achieve. The "few" lines of data you posted seem to be in two sections headed "0" and "1" each having many lines of data in the form:-

0 2:-0.5795 3:0.33582025 4:55.8255 5:65.316997 ...

Please correct me if that is wrong. Your @arr1 appears to be a selection of the initial parts of the data lines in an apparently random order. Is this order to be preserved in your output file and do you want a separate output file for each section? Depending on the answers to these questions you might be better off using hashes rather than arrays.

Cheers,

JohnGG


In reply to Re: Data extraction with specific keywords by johngg
in thread Data extraction with specific keywords by neeraj_kr

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.