in reply to Re^3: regex help!
in thread regex help!

A quick couple things. The first reason I didn't post code, or output, is because I couldn't figure out how to use the tags for presenting it and I felt like an idiot. Like I said I'm new, so thanks for bearing with me. In any event, here is what I had done:
#!/usr/local/bin/perl -w print "Enter an output file to analyze: "; chomp ($phoenix_out= <STDIN>); open (OUTPUT_FILE, "$phoenix_out") or die "can't open $phoenix_out: $! +"; while (<OUTPUT_FILE>) { chomp; if (/0 EID: 93237 /){ print "$.\n"; next; print "anything?\n"; ($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l) = split; $ND243 = $i; print "The amount of Am243 is $ND243\n"; } #else { print "$. Problem!" }; }
What I couldn't figure out was how to get it to go to the line after the data that I found. (I realized the line above the data was a unique line and that I could search for it directly). An example of the output is as follows:
0 EID: 93237 93238 93239 94240 ND : 1.8833E-06 3.1143E-09 9.6338E-07 1.9309E-05 WT%: 8.2146E-03 1.3642E-05 4.2377E-03 8.5291E-02
The data extends longer across the page, but in the interest of width I didn't include all of it, it's just the same pattern repeated. Lastly, my attempt to understand your file:

match according to NP, then white space, then U, then white space, then Pu ending ... case insensitive. Last if there is no more data? Also, next loop if there is a match? Is this what moves you to the next line down? Break up the current data into substrings, I can figure out what the nomenclature means although I don't know it offhand, I have books I can read it from. Print off the results.

Again, thank you for the help, sorry for sucking at my posts early on, and any clarifications you would like to provide would be much appreciated.

Replies are listed 'Best First'.
Re^5: regex help!
by GrandFather (Saint) on Sep 16, 2005 at 23:31 UTC

    Good post, you are getting the hang of it :).

    The substr stuff in my code uses the two special arrays @- and @+ which store the start and end points for the captures in the previous match. So, as you say the next if line skips the data line just read in the last if line, but when the header line didn't match.

    Don't worry about how bad your first post might be. You are learning fast and the other monks will smile at you as they pass in the hall.


    Perl is Huffman encoded by design.