This should work. Don't forget to substitute your filename for the one I used.
use strict; my @file; my @report = qw(sqltable mike_test sarak_mike); open INFILE, "<mms_tableload.txt"; ## The following statement stuffs the lowercased first "word" of each +record into @file. push @file, lc((split)[0]) foreach (<INFILE>); my $i = 0; foreach (@file) { print "\@file[", $i++, "] = '$_'\n"; } print "\n\n"; my %in_file = map{$_ =>1} @file; my $all_match = 1; foreach (@report) { if (! exists $in_file{$_}) { $all_match = 0; print "\@report value: '$_' is not in \@file.\n"; } }
Where the data file for @file looks like this:
Mike table loaded successfully 2001-11-26 00:34:58.61 with 284734 reco +rds. MiKe_Test table loaded sucessfully 2001-11-26 01:31:08.88 with 498 rec +ords. sarak_Mike table loaded successfully 2001-11-26 01:37:07.85 with 165 r +ecords. Inv_hdr table loaded successfully 2001-11-26 01:45:04.79 with 165321 r +ecords.
The output:
@file[0] = 'mike' @file[1] = 'mike_test' @file[2] = 'sarak_mike' @file[3] = 'inv_hdr' @report value: 'sqltable' is not in @file.

--Jim


In reply to Re: Re: Re: Re: Re: comparing two arrays by jlongino
in thread comparing two arrays by jdelmedi

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.