develooper Front page | perl.beginners | Postings from February 2009

Re: Reading 2 array lists

Thread Previous
From:
Gunnar Hjalmarsson
Date:
February 18, 2009 16:26
Subject:
Re: Reading 2 array lists
Message ID:
20090219002630.19902.qmail@lists.develooper.com
mritorto wrote:
> guys
> 
> I am new to perl scripting.
> 
> I am trying to read 2 different txt files into 2 different arrays.
> 
> My goal is to have a script read them both and print out any
> differences.
> 
> 
> Here is the script - it only prints out some of the files that end in
> a *.cer extentions but is miss the other info
> 
> 
> ###### perl script
> 
> #! ./perl
> #compares directories on 2 servers
> open (INPUT, "<atlasdirectorylisting.txt");
> open (INPUT2, "<ISISdirectorylisting.txt");
> open (OUTPUT,">compare.log");
> @lines = <INPUT>;
> @lines2 = <INPUT2>;
> 
> %lines = map {$_,1} @lines;
> @difference = grep {!$lines {$_}} @lines2;
> print "@difference\n";
> 
> print OUTPUT "@difference\n";
> 
> close (INPUT);
> close (INPUT2);
> close (OUTPUT);
> 
> 
> ####################contents of atlasdirectorylisting.txt####
> 
> .
> ..
> 3ACC91EF-E063-4C88-9728-71E222608D14.cer
> AE72EA9F-93B1-4834-86CE-FD68E78FAB07.cer
> CORPACTION_data.mdf
> CORPACTION_log.ldf
> distribution.LDF
> distribution.MDF
> DML_data.mdf
> DML_Log.ldf
> DTCC.mdf
> DTCC_log.ldf
> FEE.mdf
> FEE_log.ldf
> GPLUS_data.mdf
> GPLUS_log.ldf
> LAVA_Data.MDF
> LAVA_Log.LDF
> lumigent.mdf
> lumigent_log.LDF
> Mobetter_data.mdf
> Mobetter_index1.ndf
> Mobetter_log.ldf
> MSSQL.1
> MSSQL.2
> ProdSupport.mdf
> ProdSupport_log.ldf
> Reference_Data.MDF
> Reference_Log.LDF
> Staging_Data.MDF
> Staging_Log.LDF
> Sumicastx_data.mdf
> Sumicastx_log.ldf
> test.mdf
> test_log.ldf
> 
> 
> ####contents of ISISdirectorylisting.txt");
> 
> .
> ..
> 7FAEBFBC-60F4-478A-A907-02C3CD227FCF.cer
> CORPACTION_data.mdf
> CORPACTION_log.ldf
> D6EB2208-44E8-4552-AE7F-D025DC0C944D.cer
> distribution.LDF
> distribution.MDF
> DML_data.mdf
> DML_Log.ldf
> FEE.mdf
> FEE_log.ldf
> GPLUS_data.mdf
> GPLUS_log.ldf
> LAVA_Data.MDF
> LAVA_Log.LDF
> lumigent.mdf
> lumigent_log.LDF
> Mobetter_data.mdf
> Mobetter_index1.ndf
> Mobetter_log.ldf
> ProdSupport.mdf
> ProdSupport_log.ldf
> Reference_Data.MDF
> Reference_Log.LDF
> Staging_Data.MDF
> Staging_Log.LDF
> Sumicastx_data.mdf
> Sumicastx_log.ldf
> test.mdf
> test_log.ldf
> 
> 
> ####contents of compare (output) txt file
> 
> 7FAEBFBC-60F4-478A-A907-02C3CD227FCF.cer
>  D6EB2208-44E8-4552-AE7F-D025DC0C944D.cer
> 
> What am i missing?

Reading the Perl FAQ, perhaps?

     perldoc -q difference.+arrays

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About