Ok, I've come a lot further since I last followed up on the replies I've gotten. Below is the script that I have. Here's the low down. I have a master file and it has some lines in that I'm trying to match to another file; the other file has a field in it that I would like to place in the master file. Both files have a key that I'm using to compare the rows and that's actually an IP Address.
My Problem is that there are some records that are in the master file that are not in the other file and when I check my output those records don't show. So that's one thing I'm looking for and the other works the other way around in that there are some records in the other file that are not in the master file. Pretty much I want every line from both files in the output file.
If there is anyone that can look at the code below and modify it to where it will do just that?
#!perl #perl "copy of findandreplaceemail2.pl" -d . -i "Reporting Devices_01- +03-2009-09-00-00.csv" -s "Master Sched.csv" -o "Master Sched(new1).cs +v" use Getopt::Long; use Text::CSV; &GetOptions('d=s' => \$baseDir ,'i=s' => \$inFlNm ,'s=s' => \$subFlNm ,'o=s' => \$outFlNm ,'h' => \$hlp ,'hlp' => \$hlp ,'help' => \$hlp); $emailList = "test.csv"; $csv = Text::CSV->new(); # Save substitution data in memory indexed by manager email address open IN1, "<"."./$baseDir/$subFlNm" or die "Can't open input file >$su +bFlNm<\n"; open OUT, ">"."$baseDir/$outFlNm" or die "Can't open output file >$out +FlNm<\n"; while(<IN1>){ chomp; $_ =~ s/\,\,$//; $csv->parse($_); @subIn = $csv->fields(); $subRcd{$subIn[2]} = $_; #print "@subIn\n"; } close IN1; #There's got to be a way to take all of the Master file and use it in +the while loop open IN1, "<"."./$baseDir/$subFlNm" or die "Can't open input file >$su +bFlNm<\n"; while ($in1 = <IN1>){ chomp($in1); @mainFlds = split(/,/, $in1); $mainFlds[2] =~ s/^\s+//; $mainFlds[2] =~ s/\s+$//; if($in1 =~ /\d+\.\d+\.\d+\.\d+/){ open IN2, "<"."$baseDir/$inFlNm" or die "Can't open input file + >$inFlNm<\n"; while ($in2 = <IN2>){ chomp($in2); @subFlds = split(/,/, $in2); if($in2 =~ /\d+\.\d+\.\d+\.\d+/){ $subFlds[1] =~ s/^\s+//; $subFlds[1] =~ s/\s+$//; if("$mainFlds[2]" eq "$subFlds[1]" && "$mainFlds[1]" e +q "$subFlds[0]"){ if($in1 =~ /,,$/ || $mainFlds[7] ne '' || $mainFld +s[8] ne ''){ print OUT "$in1,$subFlds[5]\n"; } elsif ($mainFlds[6] ne ''){ print OUT "$in1,,$subFlds[5]\n"; } else { print OUT "$in1,,,$subFlds[5]\n"; } } } } close IN2; } elsif(($mainFlds[2] eq '' || $mainFlds[3] eq '') && $mainFlds[5] n +e '') { open IN2, "<"."$baseDir/$inFlNm" or die "Can't open input file + >$inFlNm<\n"; while ($in2 = <IN2>){ chomp($in2); @subFlds = split(/,/, $in2); if($subFlds[1] eq ''){ #print ">@subFlds\n"; $subFlds[1] =~ s/^\s+//; $subFlds[1] =~ s/\s+$//; if("$mainFlds[3]" eq "$subFlds[2]" && "$mainFlds[4]" e +q "$subFlds[3]" && "$subFlds[4]" ne ''){ if($in1 =~ /,,$/ || $mainFlds[7] ne '' || $mainFld +s[8] ne ''){ print OUT "$in1,$subFlds[5]\n"; } elsif ($mainFlds[6] ne ''){ print OUT "$in1,,$subFlds[5]\n"; } else { print OUT "$in1,,,$subFlds[5]\n"; } } } } close IN2; } else{ if($in1 =~ /Date/){ @date = split(/_/, $inFlNm); $date[1] =~ s/\-\d\d\-\d\d\-\d\d\.csv//; print OUT "$in1,$date[1]\n"; } else{ print OUT "$in1\n"; } } next; }

In reply to Re^2: How to go about this? by meredib
in thread How to go about this? by meredib

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.