Matt Garrish wrote:
> "Paul Lalli" <> wrote in message
> news: oups.com...
> > Matt Garrish wrote:
> >> > wrote:
> >> >> I am a Perl newbie ... absolute newbie. I need to parse a validate the
> >> >> data in a text file containing delimited records. I might need to
> >> >> sanitize some of the data and edit and save the file as I read through
> >> >> it. For example, removing negative signs from integer fields,
> >> >> truncating decimal points and digits following it in fields which are
> >> >> meant to be integers, converting all different allowable date formats
> >> >> into one common format.
> >> A module like Text-CSV might be a better option for a newbie than
> >> pointing
> >> them to regular expression parsing.
> >
> > Really? Text::CSV would help with removing negative signs, truncating
> > decimals, or converting date formats?
> >
>
> How did you get from parsing the file into chunks into performing data
> validation? I could equally well ask you how removing negative signs,
> truncating decimals and converting dates would help break up the file, but
> that sort of illogic won't get us too far will it?
.... at least one of us is either confused or stubborn to the point of
absurdity[1]. The OP asked for help doing two things: parsing the
file, and validating/"sanitizing" the resulting fields, listing a few
examples of the type of validation/sanitization he wants to accomplish.
My response included perldocs about regular expressions, intended to
help with the second part of the goal. You responded that I should
have recommended Text::CSV *instead of* regular expressions. I
questioned how Text::CSV would be able to fulfill this second goal.
End result - the OP should look at both. Text::CSV could be used for
parsing the data into fields, and regular expressions for validating
the resulting fields.
Paul Lalli
[1] And I make no assumption that that one isn't me.