tcf03 has asked for the wisdom of the Perl Monks concerning the following question:
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
Here is the code I currently have and am having a hrd time getting past this point...fileA A,B,C,D fileB A,E,F,G,H New File (fileC) A,B,D,G
The actual new file Ill need will contain#!/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"; }
$machine,$luser,$user,$hacked,$locale
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reprise searching two files
by osunderdog (Deacon) on Dec 23, 2004 at 15:27 UTC | |
|
I don't really understand the existing code but...
by tphyahoo (Vicar) on Dec 23, 2004 at 16:18 UTC |