I have a file of CSV in the format:
ID PIN
1111 1234
I need to remove a list of numbers that I have in another format in the same format.
My original thought was to read everything into an array and remove it that way, the problem I am running into is when I read it in it separates the ID and pin into different entries in the array: ie
@originalList = <LISTFILE> $originalList[0] = "ID" $originalList[1] = "PIN"
so then I thought if I could just parse through the file then I could pull out the items that don't match:
open (ORGLIST, "<", $ARGV[1]); open (BEEPON, ">>", "beep_on.list"); open (BEEPOFF, ">>", "beep_off.list"); my $i = 0; foreach my $line (<ORGLIST>){ my $notLine = 0; open (DELLIST, "<", $ARGV[0]); foreach my $otherLine (<DELLIST>){ if ($line eq $otherLine){ $notLine++; last; } } close (DELLIST); if ($notLine > 0){ print BEEPON $line; $i++; } elsif ($notLine == 0){ print $line; print BEEPOFF $line; } } close (BEEPON); close (BEEPOFF); print "Items removed $i \n"; close (DELLIST);
as you can see this code is defunct too...
This makes a list for every iteration of the file line.
any suggestions please?
I'm not looking for someone to write the code for me, I just need someone to point me in the right direction.
In reply to Search and Remove by PyrexKidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |