I have output from a program that looks like this
# Output from 'compseq' # # The Expected frequencies are calculated on the (false) assumption th +at every # word has equal frequency. # # The input sequences are: # 2L Word size 1 Total count 48795086 # # Word Obs Count Obs Frequency Exp Frequency Obs/Exp Freque +ncy # A 13340410 0.2733966 0.2500000 1.0935 +864 C 10686861 0.2190151 0.2500000 0.8760 +604 G 10692025 0.2191209 0.2500000 0.8764 +838 T 13352116 0.2736365 0.2500000 1.0945 +460 Other 723674 0.0148309 0.0000000 10000000000.00 +00000
Sometimes the Other   ... line can be missing, and the output ends with the T .... line. I'm trying to extract four values from this:
(1) The value next to Total count
(2) The first column next to G
(3) The first column next to C
(4) The first column next to Other, if it exists.
My regular exprn looks like this:
$compseqOutput =~ m/Total\scount\s+(\d+).+? C\s+(\d+).+? G\s+(\d+).+? (?:Other\s+(\d+))?/sx
, where I'm trying to allow for the fact the Other... line might not be found in $compseqOutput. For some reason, it fails when I have this -- it works perfectly when the expression is
$compseqOutput =~ m/Total\scount\s+(\d+).+? C\s+(\d+).+? G\s+(\d+).+? Other\s+(\d+)/sx
, but obviously that doesnt do what I want it to. I know I can get around this in many ways, but why does this not work?

In reply to Regular Expn Problem by venkatr_n

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.