in reply to Re: Compare CSV files
in thread Compare CSV files

Handy code, but it does suffer the problem that the commas might be quoted or that there are newlines in quotes (a common problem with hand-rolled CSV parsers). If the OPs CSV files are simple enough, then your code will be useful. Otherwise, he or she may be forced to find a way to sneak in modules (which is often much easier than it sounds).

In any event, take my comments as caveats, not criticisms :) Your code has a good chance of working for simple CSV files.

Cheers,
Ovid

New address of my CGI Course.

Replies are listed 'Best First'.
Re^3: Compare CSV files
by davorg (Chancellor) on Jul 19, 2006 at 16:07 UTC
    he or she may be forced to find a way to sneak in modules

    Or, alternatively, try the standard Text::ParseWords module. I've never understood why that module isn't used more widely.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re^3: Compare CSV files
by Moron (Curate) on Jul 19, 2006 at 16:07 UTC
    Very true. I think I once wrote a simple Split routine that walks through strings willy-nilly where I was in a "no module" situation like the OP combined with applicability of the caveat you describe.

    -M

    Free your mind