I went back to my books to refresh my memory on how to use references. Your
suggestion help a lot, but the subroutine returns wrong values. I did some small modifications on the codes below
, and tried it. It return perl-5.8.0-80.3.i386.rpm and samba-2.2.7-5.8.0.i386.rpm, which is wrong because:
1. The perl version available on the ftp server is higher.
2. The samba version already installed is higher than the one on the ftp server.




my @remote_packages = qw(perl-5.8.0-88.3.i386.rpm
samba-2.2.7-5.7.0.i386.rpm bob-5.3.2.4.1.rpm xml-2.5.2.1.rpm);
my @installed_packages = qw(perl-5.8.0-80.3.i386.rpm
samba-2.2.7-5.8.0.i386.rpm bob-5.3.2.4.1.rpm);

# I expect perl-5.8.0-88.3.i386.rpm to be returned here.


my $need_list = check_lists([EMAIL PROTECTED] , [EMAIL PROTECTED]);
foreach my $pkg (@$need_list)
{

#
$ftp_server->get($pkg) ;


}
#------------------------
#
sub check_lists
{
my ($src, $dst) = @_;
#Making a quick pick hash
my %src_hash = map { $_ => 1 } @$src;
my @need_list;
foreach my $key ( @$dst )
{
push(@need_list, $key)
unless(exists($src_hash{$key}));




}
# It should return only packages that are higher than those I've already installed.
[EMAIL PROTECTED];
} # end of check_lists




---





-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to