If

Then this extraction code may be useful:
c:\@Work\Perl\monks>perl -wMstrict -le "my @lines = ( qq{TPSM seed 234B8177 pass 1 x 2 x 50 errors 0 pid 34562 rulefi +lecycle 0\n}, qq{TPSM seed 234B8177 pass 1 x 2 x 50 errors 0 pid 34562 rilefu +llcycle 0\n}, ); ;; my $d_num = qr{ \d+ }xms; my $h_num = qr{ [[:xdigit:]]+ }xms; ;; for my $line (@lines) { print qq{[[$line]]}; ;; my $match = my ($seed, $p1, $p2, $p3, $err, $pid, $rfc) = $line =~ +m{ \A TPSM \s+ seed \s+ ($h_num) \s+ pass \s+ ($d_num) \s+ x \s+ ($d_num) \s+ x \s+ ($d_num) \s+ errors \s+ ($d_num) \s+ pid \s+ ($d_num) \s+ rulefilecycle \s+ ($d_num) \s* \Z }xms; ;; if ($match) { print qq{line ok, seed $seed p1 $p1 p2 $p2 p3 $p3 err $err +pid $pid rfc $rfc \n}; } else { print qq{line malformed}; } } " [[TPSM seed 234B8177 pass 1 x 2 x 50 errors 0 pid 34562 rulefilecy +cle 0 ]] line ok, seed 234B8177 p1 1 p2 2 p3 50 err 0 pid 34562 rfc 0 [[TPSM seed 234B8177 pass 1 x 2 x 50 errors 0 pid 34562 rilefullcy +cle 0 ]] line malformed

I understand that this code is perhaps a bit advanced for you right now, but this is a learning experience. Please consider carefully the wise advice of haukex, and also see perlre and also some of the Pattern Matching, Regular Expressions, and Parsing tutorials in the PerlMonks Tutorials section.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Searching a string in running file by AnomalousMonk
in thread Searching a string in running file by t-rex

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.