"remove space after "FIRST'" ++

But the output from your code above is:

IJK1234 Use of uninitialized value in print at F:\_wo\pl_test\733761b2.pl line + 16. ABCD Use of uninitialized value in print at F:\_wo\pl_test\733761b2.pl line + 16.

...which doesn't capture the phone number.

So, perhaps one might wish to capture the phone in the manner below and avoid the uninitialized warnings re the case where "FIRST" is empty:

foreach my $item(@strings) { print "in ENV Not Running: " . $1 if ($item =~ /ENV\(([^)]*)\) STATU +S\(Not Running\)/); $item =~ /^PRINT NAME FIRST\(([^)]*)\).* PHONE\((.+)\)/; if ($1 && $2) { print "in PRINT NAME FIRST: $1, " . $2; } }

OUTPUT:

in ENV Not Running: IJK1234 in PRINT NAME FIRST: ABCD, 12345678

Note that adding the labels to the output may bollix further processing, depending on where OP is going with this.


In reply to Re^2: Regular Expression - print out certain sections of line based on the content by ww
in thread Regular Expression - print out certain sections of line based on the content by jas999

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.