Thank you I figured it out. I didn't even think about using a hash but what you said is a good rule of thumb.
#!perl use Text::CSV; $file1 = 'Master Sched.csv'; $file2 = 'Devices_01-03-2009-09-00-00.csv'; $csv = Text::CSV->new(); open IN1, "<"."$file1" or die "Can't open input file >$file1<\n"; while(<IN1>){ chomp; $csv->parse($_); @subIn = $csv->fields(); $agentName{$subIn[1]} = $_; $IP{$subIn[2]} = $_; $hostName{$subIn[3]} = $_; $product{$subIn[4]} = $_; foreach $x ( $agentName{$subIn[1]} ){ #print "$agentName{$subIn[1]}\n"; } } close IN1; open OUT, ">>"."$file1" or die "Can't open output file >$file1<\n"; print OUT "\n"; print OUT ",Differences\n"; open IN2, "<"."$file2" or die "Can't open input file >$file2<\n"; while ($in2 = <IN2>){ if($in2 =~ /Agent Name/){ next; } @subFlds = split(/,/, $in2); if($in2 =~ /\d+\.\d+\.\d+\.\d+/ || $subFlds[2] ne ''){ chomp $in2; $subFlds[1] =~ s/^\s+//; $subFlds[1] =~ s/\s+$//; $w = $agentName{$subFlds[0]}; $x = $IP{$subFlds[1]}; $y = $hostName{$subFlds[2]}; $z = $product{$subFlds[3]}; #print "$in2\n"; #print length($w)."w\n"; #print length($x)."x\n"; #print length($y)."y\n"; #print length($z)."z\n"; if(length($w) > 0 && length($x) > 0 && length($y) > 0){ $csv->parse($IP{$subFlds[1]}); @subFlds = $csv->fields(); #print "$in2\n"; }else{ print OUT ",$in2\n"; } } }

In reply to Re^2: Return rows from 2 csv files that don't match by meredib
in thread Return rows from 2 csv files that don't match 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.