OK again I have two files, scanned.txt and importtodb.csv. both contain data separated by commas and the first item on each list is a machine name,

first I want tofind the common machine names in both and then make a new file of comma delimited values made up of items from each. ie

fileA A,B,C,D fileB A,E,F,G,H New File (fileC) A,B,D,G
Here is the code I currently have and am having a hrd time getting past this point...
#!/usr/bin/perl use strict; use warnings; my %scanned=(); my %import=(); my @LIST=(); open(SCAN, "scan3.txt") || die "$!\n"; while (<SCAN>) { my ( $machine, $luser, $hacked, $privel, undef ) = split(/,/,$_); $scanned{$machine}=[ $luser, $hacked, $privel ]; } close (SCAN); open(IMPORT, "importtodb.csv") || die "$!\n"; while (<IMPORT>) { my ( $machine, $user, undef, undef, undef, undef, $locale, und +ef ) = split(/,/,$_); $import{$machine}=[ $user, $locale ]; } close (IMPORT); foreach my $machine (keys(%scanned)) { if(exists($scanned{$machine})) { push(@LIST, $machine); } } foreach my $item(@LIST){ print "$item\n"; }
The actual new file Ill need will contain
$machine,$luser,$user,$hacked,$locale


In reply to reprise searching two files by tcf03

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.