Thanks everyone for your help. I had wondered about using a %file, but I wanted a 2 dimentional array, so figured that would be how to get one. :/ I have taken out reading into $file, and opened the list straight into INFO, and gone with a hash table. My teammates asked that I print the IP if I couldn't find it in the table, so I added an else. I'm still working on the hash table, to make sure I don't need more than those 2 fields. Its been over 10 years since I did any Perl scripting, so I am WAY out of practice! Here is the second interation of code: #!/perl # open(INFO, '<IPs.txt' ) or die; @lines1 = <INFO> ; close(INFO) ; my %table open(IN, '<source.txt' ) or die; while (<IN>) { chomp; my($ip, $country) = split(' ',$_,2); $table($ip) = $country; } open(OUT, ">>conversion.txt") or die; foreach $line1 (@lines1) { if (exists $table($line1)) { if $line2 =~ /$line1/ ; print OUT $line1, ' ',$table($line1),"\n" ; else else print OUT $line1; } } close OUT;

In reply to Re: Re: Comparing 1 list and 1 array by Anonymous Monk
in thread Comparing 1 list and 1 array 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.