Dearest Monks,
I'm having problems getting a regex to match the following line and split the colls into an array. Please insert the tabs where you would expect them.
OA P total M total F total M 0 M1-4 M 5-9 M 10-14 + M 15-19 M 20-24 M 25-29 M 30-34 M 35-39 M 40-44 + M 45-49 M 50-54 M 55-59 M 60-64 M 65-69 M 70-74 M +75-79 M 80-84 M 85+ F 0 F 1-4 F 5-9 F 10-14 F15- +19 F 20-24 F 25-29 F 30-34 F 35-39 F 40-44 F 45-49 + F 50-54 F 55-59 F 60-64 F 65-69 F 70-74 F 75-79 +F 80-84 F 85+
The regex I am using is:
if (my @match_A = $line =~ /^([^\t]+)\t #1 ([^\t]+)\t #2 ([^\t]+)\t #3 ([^\t]+)\t #4 ([^\t]+)\t #5 ([^\t]+)\t #6 ([^\t]+)\t #7 ([^\t]+)\t #8 ([^\t]+)\t #9 ([^\t]+)\t #10 ([^\t]+)\t #11 ([^\t]+)\t #12 ([^\t]+)\t #13 ([^\t]+)\t #14 ([^\t]+)\t #15 ([^\t]+)\t #16 ([^\t]+)\t #17 ([^\t]+)\t #18 ([^\t]+)\t #19 ([^\t]+)\t #20 ([^\t]+)\t #21 ([^\t]+)\t #22 ([^\t]+)\t #23 ([^\t]+)\t #24 ([^\t]+)\t #25 ([^\t]+)\t #26 ([^\t]+)\t #27 ([^\t]+)\t #28 ([^\t]+)\t #29 ([^\t]+)\t #30 ([^\t]+)\t #31 ([^\t]+)\t #32 ([^\t]+)\t #33 ([^\t]+)\t #34 ([^\t]+)\t #35 ([^\t]+)\t #36 ([^\t]+)\t #37 ([^\t]+)\t #38 ([^\t]+)\t #39 ([^\t]+)\t #40 ([^\t]+)\t #41 ([^\t]+)\t #42 # (.{1,}\t) #42 /x) {
The error message I get is:
Use of uninitialized value in pattern match (m//) at reformat_text_fil +e.pl line 125, <FILE> line 4.

In reply to Regex to match a line by Win

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.