Hi Ovid,

You wrote:

As it turns out, each line of the file represents one type of quote and the format and the format, while consistent for each quote type, varies from type to type. In other words, one line may have five fields and the next line may have eight.

It seems to me that by the time you've done something like

while(<DATA>) { chomp; my @line = split(',',$_); }

then you can be fairly certain of a few things:
@line[0] is the request type
@line[@line-2] is the date
@line[@line-1] is the timestamp
(And after you verify those with your regexes then
you'll know it for sure).

It seems to me that anything from @line[1..(@line-3)]
is the data you are interested in. This is one way to deal
with variable-length fields in your data:

#!/usr/bin/perl while(<DATA>) { chomp; /^$/ and next; my @line = split(/,/,$_); for(@line[1..(@line-3)]) { /\d+\.[\d]{4}/ or next; printf("%s\t%s\n",$line[0],$_); } } exit;

I haven't done any of the nifty stuff you are doing-
building references etc.- because I still have a hard time
grokking them...

Tentatively,
blyman


In reply to Re: A Slough of ParseRecDescent Woes by belden
in thread A Slough of ParseRecDescent Woes by Ovid

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.