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

Re: Reading 2 array lists

Thread Previous | Thread Next
From:
Chas. Owens
Date:
February 19, 2009 08:44
Subject:
Re: Reading 2 array lists
Message ID:
58ce48dc0902190843y3b81543fqdaa5e0f50ff488ae@mail.gmail.com
On Thu, Feb 19, 2009 at 10:20, mritorto <mritorto@gmail.com> wrote:
> owen,
>
> How do you use the List::Compare module is the same as array::compare?
snip

List::Compare can be found in CPAN*.  Here is you program rewritten to
use it (this is not what I would do):

#!/usr/bin/perl

use strict;
use warnings;
use List::Compare;

#compares directories on 2 servers
open my $atlas, "<", "atlasdirectorylisting.txt"
	or die "could not open atlasdirectorylisting.txt: $!";
open my $isis, "<", "ISISdirectorylisting.txt"
	or die "could not open ISISdirectorylisting.txt: $!";

my @atlas = <$atlas>;
my @isis  = <$isis>;

my $comparison = List::Compare->new(\@atlas, \@isis);

print $comparison->get_symmetric_difference;

* http://search.cpan.org/dist/List-Compare/lib/List/Compare.pm

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

Thread Previous | Thread Next


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