I have a massive CSV file that I am trying to process to remove multiple entries.
Really I would like to have two files when I am done, the new dup free list and a list of removed entries.
The csv file is in this format:

Group One,Captain,Phone Number,League Pos,etc.
Group-One,Captain,Phone Number,League Pos,etc.
GroupOne,Captain,Phone Number,League Pos,etc.
Group Two,Captain,Phone Number,League Pos,etc.
Group Three,Captain,Phone Number,League Pos,etc.
Etc. Etc. Etc.

my thinking is to pull out the company name from each line then compare it to the rest of the file. I'm still new to regex and I'm running into multiple problems:
#!/usr/bin/perl use strict; use warnings; open my $FHIN, '<', $ARGV[0]; open my $FHOUT, '>', "$ARGV[0].new"; open my $DELLIST, '>', "ARGV[0].deleted"; foreach (<$FHIN>){ $_ =~ s/\"//g; $_ =~ m/(.*?),/i; my $tmp = $1; open my $SCRATCH, '<', "./scratch.pad"; open my $TMPOUT, '>', "./tmp.out"; foreach (<$SCRATCH>){ $_ = m/$tmp/ ? print $DELLIST $_ : print $TMPOUT $_; } close $SCRATCH, $TMPOUT; cp ($TMPOUT, $SCRATCH); }

First, there has to be a better way than iterating through the file for each line of the file.
Second, I'm not sure what I changed, but now I am receiving these two errors:
Filehandle $TMPOUT opened only for output at /usr/share/perl/5.10/File +/Copy.pm line 200. stat() on closed filehandle $SCRATCH at /usr/share/perl/5.10/File/Copy +.pm line 117.

And finally, The dup entries with special characters are not counted as dups... Would doing a s/r for every special character ie:
$_ =~ s/[-|\&|_|+|']/ /g;
work to make all the entries similar enough?

Thanks in advance for the assist.

EDIT

in Lieu of:
$_ =~ s/[-|\&|_|+|']/ /g;
How about:
<c> $_ =~ s/\W/ /g;

In reply to Remove duplicate entries by PyrexKidd

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.