Let me write a hypothetical question for you that may or may not be what you were trying to ask:

Most wise monks, I am very new to Perl but have been given a large data file to read that was generated by an old Fortran program. The data are in pairs of lines with a header line and a data line like this:

000 NP U Pu 001 1.270000 000001 3.141000 002 Lev N Pu 003 0.13 000001 3.277118 004 NP U Pu 005 1.000220 000002 3.098761 006 Yac S Yb 007 10.33000 000001 90000000

I need to extract the NP U P lines of data. I have worked out how to read the file. But I can't figure out how to find the data. My code so far looks like this:

open I,"data.dat"; for($I=0;$I<1000;++$I) { $l1=<I>; chop $L1; $L2=<I>; chop $L2; #find the data here printf ("%d, %d, %d\n", $N1, $N2, $n3); }

Can someone help me with the code I need to replace the comment please?


Perl is Huffman encoded by design.

In reply to Re: regex help! by GrandFather
in thread regex help! by igotlongestname

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.