Hi Monks , Can you see the problem with my code? I am comparing two files and printing the different out.
scheduled contact.txt --------- ----------- Sam 5:00 sam 324-232-3333 scott 4:45 Joe 235-309-3333 saleem 5:00 Saleem 323-747-0000 Ken 7:00 Ken 764-636-9999 Ken 8:00 open (FILE1, '<', 'scheduled') or die "Unable to open file1.txt for re +ading : $!"; open (CONTACT, '<', 'contact.txt' ) or die "Unable to open contatct.tx +t: $!"; while (my $list = <CONTACT>) { chomp $list; my @names = split(/ /, $list); my $name = ($names[0]); open (FILE3, '>>', 'Available') or die "Unable to open Tuesday.rep for + writing : $!"; while (my $line = <FILE1>) { chomp $line; unless ($line =~ m/^$name/) { #print FILE3 "$list\n"; print " the line is $list\n"; print " the sched is $line\n"; } } }
what I am doing is trying to print the contact of the person who is not in the schedul , in my example I will need to only print  Joe 235-309-3333 My code is doing it wrong and also check for ken who is schedul twice , two times which I dont' want . If the person is schedul then I don't need to print it . Can you help?

In reply to not able to compare files by Anonymous Monk

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.